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 V5.07.08 betas
Page 2 of 11 | |||||
Author | Message | ||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9126 |
I think I've found it. The issue is that when a defined time is set for the tone the interrupt routine shuts it off at the appropriate time. However, if this happens at exactly the same time as you are renewing the tone then data that the command is using can be inconsistent. I've changed the code to extend the previous tone right at the top of the play tone command so that it should be impossible for the tone to terminate in the interrupt while the new tone is calculated and set up. Try this and let me know PicoMite (6).zip |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
I can try tonight. Currently only have a VGA board with me. Volhout PicomiteVGA PETSCII ROBOTS |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4043 |
Right, so I didn't look hard enough . An interrupt can call StopAudio() and stomp on the state whilst the main thread of control is running through cmd_play(). I know nothing of this level of interrupts, but I wonder if it might be better for the interrupt to set a flag that the main thread of control can then inspect at an appropriate safe point to determine if StopAudio() needs to be called, just as we would recommend for an MMBasic s/w interrupt. Though, that's easy for me to say . I will, but it will probably have to wait until this evening. I have high confidence though . Thank you, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
@Peter, It has changed. But it is not solved. The error message is gone. Now, every time the sound stops (silence). Sometimes after few seconds, sometimes after minutes. Once I had it running for several minutes, before it stopped. I may be related to the random frequencies in the array. Using this code (from previous post) Dim noise%(200) For i% = 1 To 200 : noise%(i%) = Int(Rnd * 1000) : Next Do For i% = 1 To 200 Play Tone noise%(i%), noise%(i%), 2 Pause 1 Next Loop Looking at the PWM output, the 44kHz PWM is still running, only it outputs a continuous duty cycle. Probably the last sine sample is repeated every time. Volhout PicomiteVGA PETSCII ROBOTS |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4043 |
Thanks Volhout, I had seen this issue prior to the latest fix, and once following the fix (which I agree has addressed the originally reported ERROR) but have been struggling to reproduce using the above as written. However if you remove the PAUSE it happens every time in fairly short-order. Best wishes, Tom Edited 2023-07-05 04:19 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
I run cpuspeed 126000 Maybe it is more obvious then. Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9126 |
Don't know what happened there. I'm developing on VGA and somehow screwed the conversion of the fix to non-vga Try this PicoMite.zip |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4043 |
That seems to have done the trick for me, thank you! Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
@Peter, I can confirm, even with "pause 1" removed the sound keeps running, and no error message. Tested on Picomite at 133MHz. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
@Peter, I have used VAR SAVE in my SNAKE game, and I understand why the saved variables are cleared when you load a different program in memory. In case you want to keep the variables non volatile you would need to save them to a file in the filsystem. This is absolutely do-able. But for all the variables you would have to convert to to strings, and convert back after loading. Is it technically possible to create a VAR SAVE to file ??? Something like VAR SAVE a,b,c,n() TO "filename". The VAR SAVE could simply save the 16k block as binary blob, and reload it at VAR RESTORE "filename". Of coarse mor advanced methods are also possible, but this would allow to use the VAR SAVE more flexible. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
I can't remember trying it, but can't you do: PRINT#1, A$, B, C$ and INPUT#1, A$, B, C$ ? I haven't got a Pico set up at the moment. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
> new > a$="a":b=9.87654321:c$="C" > open "var.sav" for output as #1: print #1,a$,b,c$: close #1 > new > open "var.sav" for input as #1: input #1,a$,b,c$: close #1 > ?a$,b,c$ a 9.87654321 C 0 I don't know where the "0" came from. (Picomite) And further: > ?len(c$) 0 > ?B 0 > ?a$ a 9.87654321 C Edited 2023-07-06 02:39 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3802 |
I think you need print #1, a$ print #1, b print #1, c$ and likewise for the input #1: input #1,a$ input #1,b input #1,c$ so that they're each on a line of their own. John Edited 2023-07-06 03:35 by JohnS |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9126 |
You need a delimiter on the output Try print #1,a$+","+str$(b)+","+c$ At the moment everything is being read into a$ |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3802 |
The newlines should be enough without needing a comma delimiter (I think). John Edited 2023-07-06 03:36 by JohnS |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
> new > a$="a":b=9.87654321:c$="C" > open "var.sav" for output as #1: print #1,a$,",",b,",",c$: close #1 > new > open "var.sav" for input as #1: input #1,a$,b,c$: close #1 > ?a$;"|";b;"|";c$ a| 9.87654321|C PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Thank you all for your support. This is what I meant with "absolutely doable". It is more code if you would like to do this: Dim a%(12,3,8), b$(4) VAR RESTORE Again, absolutely doable. Just more code. Volhout... PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9126 |
V5.07.08b8 https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip Fixes bug caused by race condition when PLAY TONE is used with defined time and a new tone is issued during the termination of the previous tone. NEW FUNCTIONALITY ADC RUN array1%(),array2%() MM.INFO(ADC) This new functionality allows for continuous background ADC conversion into a pair of swing buffers. As for ADC START, prepare the ADC channels using ADC OPEN. 1 to 4 ADC channels can be sampled at an overall rate of up-to 500,000 samples per second. However, unlike ADC START, the data from all channels will be 8-bit and packed into the arrays. First array%1(), then array%(2), then back to one again. etc. until ADC CLOSE is used to terminate conversion. So, if 2 channels are specified in ADC OPEN then the first element of array%(1) will contain 4 samples from ADC0 and 4 from ADC1 interleaved. The size of the arrays must be the same and defines the total number of samples. Thus DIM array%(99) will be able to hold 800 readings and in the case of our example these will be 400 from adc channel 0 and 400 from adc channel 1. You can use the MEMORY UNPACK command to move the packed data into an array that is more easily manipulated in Basic or just use the PEEK(BYTE to access individual readings. If in the ADC OPEN command you specify an interrupt then this will fire every time the ADC conversion swaps to the next array buffer. This will allow the Basic program to easily know when it can process data. MM.INFO(ADC) contains the number of the buffer which is currently not being written i.e. the data is stable so immediately after ADC RUN is called it will return 2 even though that buffer has not yet been written. As soon as it returns 1 you know that the first buffer has been completely filled and the data is available for processing. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9126 |
V5.07.08b9 https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip By popular request MOD file playback Use OPTION MODBUFF ENABLE [sizeinK] to create a buffer in the chip's flash to hold the mod file. If sizeinK is not specified then it will default to 128Kbytes Use OPTION MODBUFF DISABLE to get rid of the buffer. Both variants are permanent options. NOTE: Both commands will wipe the contents of the A: drive and when a buffer is enabled the size of the A: drive will be reduced by the size of the buffer Then, as per the CMM2, use PLAY MODFILE fname$ to play a mod file. If the .mod is omitted it will be automatically added. Remember, filenames on the A: drive are case sensitive. For info, the output is generated in stereo at 16KHz with the PWM running at 32KHz. MOD files play continuously in a loop so use PLAY STOP or Ctrl-C to terminate playback Edited 2023-07-23 02:30 by matherp |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Wauw, that is fast... I will try this on maxitrek once I am back. Currently traveling without mite... PicomiteVGA PETSCII ROBOTS |
||||
Page 2 of 11 |
Print this page |