Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:36 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Picomite(VGA) V5.07.07 betas - bug fixes + focus on PIO

     Page 2 of 16    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 09:11am 14 Jan 2023
Copy link to clipboard 
Print this post

I'm confused. Are you saying that all is OK with channel 0? Certainly looks good on my logic analyser


 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 10:10am 14 Jan 2023
Copy link to clipboard 
Print this post

Attached is a b2 for the PicoMite. Only one minor change which fixes an error introduced in V5.07.06 in drawing on monochrome displays such as the SSD1306


PicoMiteV5.07.07b2.zip
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2141
Posted: 11:20am 14 Jan 2023
Copy link to clipboard 
Print this post

Yes all good, I put the edit at the start in the hope you wouldn't waste time on it. Brand new Pico has a dud GP0. Output pulls up but not down, with only the scope impedance pulling it down the pulses were wrong.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2134
Posted: 01:18pm 14 Jan 2023
Copy link to clipboard 
Print this post

picomiteV5.07.07b2 sorted SSD1306 line and circle not working.
Thanks.

 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3816
Posted: 02:07pm 14 Jan 2023
Copy link to clipboard 
Print this post

  stanleyella said  picomiteV5.07.07b2 sorted SSD1306 line and circle not working.
Thanks.


Just wondering which of these you mean:

picomiteV5.07.07b2 sorted SSD1306. Line and circle not working.

picomiteV5.07.07b2 sorted SSD1306 line. Circle not working.

The pic you posted seems to have a circle, though.

Also, posting the code probably makes sense.

John
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2134
Posted: 05:04pm 14 Jan 2023
Copy link to clipboard 
Print this post

It was a bug in the last release that ssd1306 had no graphics, only text but the beta made graphics work again.
I did post the code or this bug would not probably be fixed.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4256
Posted: 07:52pm 14 Jan 2023
Copy link to clipboard 
Print this post

Confirm: all is good with phase correct PWM in PWM0 in beta 2.



PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 08:51am 15 Jan 2023
Copy link to clipboard 
Print this post

Picomite(VGA) V5.07.07b
https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip

Fixes bug in CHDIR converting input to lower case. NB: all flash filenames and directory names are case sensitive

Fixes bug in pixel drawing primitve for PicoMite (affected circle and line commands amongst others) using mono displays
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 10:26am 17 Jan 2023
Copy link to clipboard 
Print this post

Picomite(VGA) V5.07.07b4

https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip

Bug fix to PIO INTERRUPT not accepting 0 for TX interrupt

This version adds significant functionality in support of PIO interfacing

For high speed PIO access Basic is limited to the rate at which instructions can be executed by the interpreter. So, if we assume 240,000 instructions/second at 378MHz, allowing for a loop we can perhaps output or input a maximum of 80,000 data items per second whilst doing nothing else. This is fine for many applications but what about for using PIO to implement a logic analyser?

The solution for this is to avoid the processor having to do the work and use direct memory access (DMA) to transfer the data to or from the PIO FIFOs

The way that DMA works is as follows:

When reading from the FIFO the DMA controller waits on data being in the FIFO and when it appears transfers that data into processor memory. Each time it reads it increments the pointer into the processor memory so that it can, for example, incrementally fill an array as each and every data item is made available.

When writing to the FIFO the DMA controller writes data from processor memory to the FIFO automatically waiting whenever the FIFO is full. Thus data can be prepared in an array and the DMA controller will stream that data to the PIO FIFO as fast as the PIO program requires it.

In both cases the DMA transfers a 32-bit word to match the FIFO and when setting up DMA you need to tell it how many words to transfer. Because each transfer will increment the memory pointer by 4 bytes (a word) MMBasic must deal with the data packed into memory as 32-bit values rather than the 64-bits used for MMbasic integers and floats. Luckily MMBasic implements two commands MEMORY PACK and MEMORY UNPACK to do this very efficiently but it could equally be done using standard BASIC arithmetic.


The new commands in this release are:

PIO DMA_IN pio, sm, nbr, data%() [,completioninterrupt] [,transfersize]
PIO DMA_OUT pio, sm, nbr, data%() [,completioninterrupt] [,transfersize]


In both cases:
pio specifies which of the two pio instances to use (0 or 1) NB: 1 only for the VGA version
sm specifies which of the state machine to use (0-3)
nbr specifies how many 32-bit words to transfer
data%() is the array that will either supply or receive the PIO data
The optional parameter completioninterrupt is the name of a MMBasic subroutine that will be called when the DMA completes and in the case of DMA_OUT the FIFO has been emptied.
The optional parameter transfersize allows the user to override the normal 32-bit transfers and select 8, 16, or 32. This allows the MMBasic data arrays to be smaller if less than 32-bits is required. In all cases MEMORY PACK and UNPACK can be used to move between the compressed data and normal MMbasic integers.

If the optional interrupt is not used then the status of the DMA can be checked using the functions

NB: Do not use PIO START when using DMA. The PIO state machine is automatically started by the DMA


MM.INFO(PIO RX DMA)
MM.INFO(PIO TX DMA)


In both case these return 1 if the DMA is still running and 0 if it has completed.

Self contained examples of the DMA transfers are provided here.
Thanks to Volhout for the spade work on these examples.

Now who is going to write a multichannel logic analyser with trigger for us?
Edited 2023-01-17 21:25 by matherp
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 359
Posted: 01:32pm 17 Jan 2023
Copy link to clipboard 
Print this post

Matherp,
V5.07.07b4
PicoMite_readme.txt

..The optional parameter transfersize allows the user to override the normal 32-bit transfers and select 8, 16, or 32....

Assume it is a second optional parameter for these commands:

PIO DMA_IN pio, sm, nbr, data%() [,completioninterrupt]
PIO DMA_OUT pio, sm, nbr, data%() [,completioninterrupt]
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4256
Posted: 03:39pm 17 Jan 2023
Copy link to clipboard 
Print this post

Hi Peter,

Logic analyzer:
Gathering data is not a problem. Triggering a bit bigger problem (especially when you need complex sources). Best to do this "a-la" old Saleae's. Not really trigger, but add the trigger as a separate channel (invisible) to the DMA data, and re-aligh while processing the data.

But saleae got away with huge memory. We don't have that. So we have to do real triggering. And if you want pre-trigger data, and post trigger data, then the data capture must use a circular buffer.

I will give it a try, but will most likely end up with something that shows data starting with the trigger, and not before the trigger.

Regards,

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 04:01pm 17 Jan 2023
Copy link to clipboard 
Print this post

Picomite(VGA) V5.07.07b5

https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip

One more powerful tweak to the MMBasic PIO interface - might help the logic analyser or an arbitrary waveform generator

Another optional parameter for PIO DMA
PIO DMA_IN pio, sm, nbr, data%() [,completioninterrupt] [,transfersize] [,loopbackcount]
PIO DMA_OUT pio, sm, nbr, data%() [,completioninterrupt] [,transfersize] [,loopbackcount]
The optional parameter loopbackcount specifies how many data items are to be read or written before the DMA starts again at the beginning of the buffer
The parameter must be a power of 2 between 2 and 32768
Due to a limitation in the RP2040 if loopbackcounter is used the MMBasic array must be aligned in memory to the number of bytes in the loop (transfer size in bytes * number of transfers)
Thus if the array is 64 integers long which is 512 bytes then the array must be aligned to a 512byte boundary in memory
All MMBasic arrays are aligned to a 256 byte boundary but to create an array which is guaranteed to be aligned to a 512 byte boundary or greater a new sub command is used

PIO MAKE RING BUFFER ivar%, size

To use this command create a simple integer variable then call the command and it will be converted into an array of the size specified and aligned to the number of bytes specified.

e.g.
dim packed%
PIO MAKE RING BUFFER packed%,4096

packed% will then be an integer array holding 4096/8=512 integers
This can then be used by the DMA for a loopbackcounter with DMA of 1024 32-bit words, 2048 16-bit shorts or 4096 8-bit bytes

If a DMA is running you can abort it with

PIO DMA_IN OFF
PIO DMA_OUT OFF

Example code running  

' demo program to demonstrate the use of the PIO interrupt
' the PIO is programmed to pull 1 word from FIFO at every rising edge of the GP pin.
' the LSB 5 bits are shown on GP1..GP5 (diagnostics)
' the GP0 pin is controlled from MMBasic in this demo, but could also be driven from
' an external source.

'-------------------------------- PIO state machine -----------------------------------

'PIO clear, and attach pins to PIO 1
PIO clear 1
SetPin gp1,pio1
SetPin gp2,pio1
SetPin gp3,pio1
SetPin gp4,pio1
SetPin gp5,pio1
Dim integer unpacked%(31),packed%(15)
Dim integer packedadd=Peek(varaddr packed%())
Dim integer unpackedadd=Peek(varaddr unpacked%())
For i=0 To 31
unpacked%(i)=i
Next
Memory pack unpackedadd,packedadd,32,16

'the PIO program
'address    code    mnemonics             comment
'  0      E09F      SET pindirs &b11111   GP1..GP5 out
'  1      2000      WAIT GP0=0            wait for external trigger on GP0 to pull
'  2      2080      WAIT GP0=1
'  3      8080      PULL noblock          pulls data off fifo
'  4      6005      OUT OSR > pins 5      shift 5 bits to GP1..5 pins
'  5      0001      JMP 1                 repeat

PIO program line 1,0,&hE09F
PIO program line 1,1,&h2000
PIO program line 1,2,&h2080
PIO program line 1,3,&h8080
PIO program line 1,4,&h6005
PIO program line 1,5,&h0001


'write the configuration, running 1MHz
f=1e6
p=Pio(pinctrl 0,5,5,gp0,,gp1,gp1)    'pins GP1...GP5 = out, GP0 = in
'  s=PIO(shiftctrl 0,0,0,0,1,1)        'default value
'  e=PIO(execctrl gp0,0,31)            'default value: wrap defaults, GP0 = cond JMP pin
'  PIO init machine 1,0,f,p,e,s,0      'PIO 1 SM 0 start adress = 0
PIO init machine 1,2,f,p,,,0         'PIO 1 SM 0 start adress = 0



'-------------------------------- MMBasic MAIN ---------------------------------------

'Halt the PIO from GP0 from MMBasic before it fills the FIFO out of control
SetPin gp0,dout
Pin(gp0)=0

'variables
Dim d%=0

'start the pio1 code, state machine 1.0 will be waiting for a rising edge on the GP0 pin
'then it will pull 1 word from fifo. Then it will wait for the falling edge. The cycle repeats.

'set the dma to loop over 32 16-bit shorts for a very long time
PIO DMA_OUT 1,2,&H10000,packed%(),dmadone,16,32

'freguently PIO pull data from the fifo
SetTick 200,PullFifo


'Main: interrupt free loop polling the NOT TX_FULL flag in FSTAT
Do
If a% Then
  SetTick 0,0
  End
EndIf
Loop

End



'----------------------------------- SUBS ---------------------------------------

'in this sub we toggle the GP0 pin to force the PIO to fetch data from the FIFO
Sub PullFifo
Pulse gp0,10
End Sub

Sub dmadone
Print "All done"
a%=1
End Sub

Edited 2023-01-18 03:03 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4256
Posted: 06:07pm 17 Jan 2023
Copy link to clipboard 
Print this post

Peter,

Is there a peek to find the pointer in the array where I stopped the dma?

Not sure if I really need it, I think I can get it to work with what is in b5.
Trying some things now. May get the foundation layed tonight.

It is a miracle what is happening here. Yesterday: I may look into DMA, 24 hours later we have a working platform.
..respect man...deep bow.

Volhout

P.S. only the VGA version in the ZIP. Is that intended ?
Edited 2023-01-18 04:21 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 07:02pm 17 Jan 2023
Copy link to clipboard 
Print this post

I've updated the download with both versions and added

PIO(DMA RX POINTER)
PIO(DMA TX POINTER)
to return the current data item being written or read by the PIO
as always TX and RX from the perspective of MMBasic

so:

PIO(DMA TX POINTER)-PEEK(VARADDR packed%())

will give you the location in the data array
Edited 2023-01-18 05:03 by matherp
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 899
Posted: 06:32am 18 Jan 2023
Copy link to clipboard 
Print this post

I think its Still only the VGA version in the ZIP.
Gerry
Latest F4 Latest H7
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1110
Posted: 06:43am 18 Jan 2023
Copy link to clipboard 
Print this post

  Quote  The optional parameter loopbackcount specifies how many data items are to be read or written before the DMA starts again at the beginning of the buffer
The parameter must be a power of 2 between 2 and 32768

Is there a way to read a single value (32 bit integer?) into a variable continuously? For example, suppose the PIO is reading a suitable signal and placing the, say, total running count, into a variable. Then MMBasic can read the current value, much like it can magically read the current value of TIME$. Plus MMBasic can zero the variable, or write an arbitrary value to it as might be useful.
Visit Vegipete's *Mite Library for cool programs.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 08:29am 18 Jan 2023
Copy link to clipboard 
Print this post

  Quote  
I think its Still only the VGA version in the ZIP.


Definitely OK now

https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip
Edited 2023-01-18 18:29 by matherp
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3816
Posted: 08:42am 18 Jan 2023
Copy link to clipboard 
Print this post

  matherp said  
  Quote  
I think its Still only the VGA version in the ZIP.


Definitely OK now

https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip

Yes, thanks.

(Unable to test at all currently.)

John
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3816
Posted: 09:15am 18 Jan 2023
Copy link to clipboard 
Print this post

  vegipete said  
  Quote  The optional parameter loopbackcount specifies how many data items are to be read or written before the DMA starts again at the beginning of the buffer
The parameter must be a power of 2 between 2 and 32768

Is there a way to read a single value (32 bit integer?) into a variable continuously? For example, suppose the PIO is reading a suitable signal and placing the, say, total running count, into a variable. Then MMBasic can read the current value, much like it can magically read the current value of TIME$. Plus MMBasic can zero the variable, or write an arbitrary value to it as might be useful.

Could you (DMA) read the same thing but live with the power of 2 i.e. 2 in this case? Both values would be the same lots of the time so just ignore one of them.

John
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 09:35am 18 Jan 2023
Copy link to clipboard 
Print this post

  Quote  Is there a way to read a single value (32 bit integer?) into a variable continuously?


I'll include that in the next beta, both in and out
 
     Page 2 of 16    
Print this page
© JAQ Software 2024