PicoMite: Possible console timing issue with V5.05.05 betas


Author Message
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 10:39am 13 Sep 2022      

I think this issue may have been solved for someone a few months ago but I can't find the thread.

I have a breadboard setup with a standard PicoMite and SPI ILI9488 touchscreen with SD card, also several other modules; DS3231 RTC & BME280 using I2C, a buzzer and a single pin digital input from a 433MHz receiver module via a voltage divider. The console is connected to my Win7/64 notebook with TeraTerm at 38400 baud. It's all worked fine for six months or so up to and including V5.05.04 but for the last few beta versions of V5.05.05 it hangs when I try to run it - as shown below. I'm not sure exactly at which beta version the problem started.

Version 5.07.04 flashed, then program loaded via AUTOSAVE & ^Z - all OK
> ? mm.info(version)
5.0704
> run
'now running OK so try AUTORUN
> option autorun on
'plug into USB port and it runs OK again
> 24.69   36.76         29.99  '^C, program halted - back to console
>


Version 5.07.05b18 flashed, then program again loaded via AUTOSAVE & ^Z
>Saved 21520 bytes
> flash save 1
> run
'system hangs with just "[" on next line of console.
'USB port power cycled, splash screen overwrites the "[" character
PicoMite MMBasic Version 5.07.05b18
Copyright 2011-2022 Geoff Graham
Copyright 2016-2022 Peter Mather

>
> flash run 1
[
'gives same hanging problem and "[" response when trying from flash.


The OPTIONS and pin settings in the program are as below. A few lines of the program's BME280 initialisation (copied from PeterM's work) are included to show the non sytem I2C channel setup.
> option list
OPTION SYSTEM SPI GP18,GP19,GP20
OPTION SYSTEM I2C GP14,GP15
OPTION COLOURCODE ON
OPTION DISPLAY 40, 100
OPTION LCDPANEL ILI9488, RLANDSCAPE,GP26,GP27,GP28
OPTION TOUCH GP22,GP21,GP5
GUI CALIBRATE 0, 254, 139, 1289, 841
OPTION SDCARD GP0, GP16, GP1, GP17
>
' Pico Pin Settings
 Const highrestimer = 9, receiveblip = 11  'Pico pins 9 & 11 (GP6 & GP8)
 SetPin 4, PWM1A
 PWM 1,10000,50 'PWM1A pin 4 out to high resol'n timer on counting pin 9 (GP6).
 SetPin 9,CIN   'input (counting) pin for the high resolution timer.
 SetPin 11,INTL,blip  'input (receive) pin for data out (DO) of the 433MHz
 SetPin 16,17,I2C   'DA & CLK pins for the BME280

Sub bme280_init
 Local i%,cal%(17)
 I2C open 400,1000 '400KHz bus speed
 I2C write BME280_ADDRESS,1,1,BME280_REGISTER_CHIPID
 I2C read BME280_ADDRESS,0,1,i%
 If i%<>&H60 Then Print "Error BME280 not found"

On the face of it this looks like a problem with TeraTerm settings or the V5.05.05 betas. However I don't trust my OPTIONs, pin settings or the copied BME280 initialisation either, even though they work OK under V5.05.04. Can anyone suggest a fix?

Greg

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8684
Posted: 05:12pm 13 Sep 2022      

It is not possible to provide any useful input from the information above. I suggest you place an "END" statement soon after the beginning of the code and then move it down the code until you find what is triggering the error.
The previous issue you reference was unrelated. Make sure you are running the latest beta so we have a common point of reference.
If you are using interrupts make sure that the interrupt cannot fire until any data or I/O used in the interrupt is properly initialised. Enabling interrupts should always be the last thing you do before entering the main program.
Edited 2022-09-14 03:20 by matherp

paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:41pm 14 Sep 2022      

Thanks for having a look at the post Peter. Firstly I have to apologise for creating confusion with the Versions I posted about. They are all V5.07.xx not V5.05.xx as I mis-typed twice in the first post, including in the thread subject and the final couple of sentences of the post!

Anyway after running it happily all night on V5.07.04 I flashed it again with the latest V5.07.05b18 this morning and for several hours I've been trying to find some consistency with the problem. You mentioned interrupts and I did have a "SETPIN 9,INTL,target" declared a bit early so I moved it to immediately before the "Main" do loop as you suggested. There's also a SETTICK firing every 30 secs. to read the BME280 but that was already placed just before "Main".

I then went onto placing various PRINT "x": END statements early in the code using the internal editor, but the results were inconsistent. The one consistent thing (that I presume shouldn't be happening) is that when I hit F1 to save the edited program it prints the "xxxx bytes saved" message to the console but then immediately starts running. Sometimes it runs consistently to wherever I'd placed the END statement, but sometimes it would also just print the "[" to the console and hang again and to retrieve the console I have to power cycle.

I'm now wondering whether my Pico is a bit marginal so my next try will be to replace the Pico with a new module - I've got a couple of spares. Any further suggestions would be appreciated.

Greg

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8684
Posted: 03:51pm 14 Sep 2022      

As always try a better power source. Someone else reported the F1 issue but then did something and it went away. May be worth nuking the Pico before flashing.

paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 11:37am 21 Sep 2022      

Problem solved!
Left it for a few days but tried it again after loading Peter's release of V5.07.05RC1 last night. The same problem i.e. the RUN command returning a "[" to the console and then hanging, was still there so I tried some other changes. Turns out the position of the PWM statement was the problem.
My setup has Pin 4 (PWM out) directly connected to Pin 9 (count in) as a high resolution timer to decode 433MHz transmissions a la TassyJim and Disco4now, so it may be a particular case.

Original code.
' Pico Pin Settings
 Const highrestimer = 9, receiveblip = 11  'Pico pins 9 & 11 (GP6 & GP8)
 SetPin 4, PWM1A
 PWM 1,10000,50 'PWM1A pin 4 out to high resol'n timer on counting pin 9 (GP6).
 SetPin 9,CIN   'input (counting) pin for the high resolution timer.
 SetPin 11,INTL,blip  'input (receive) pin for data out (DO) of the 433MHz receive module.
 SetPin 16,17,I2C   'DA & CLK pins for the BME280


Changed code - as noted.
' Pico Pin Settings
 Const highrestimer = 9, receiveblip = 11  'Pico pins 9 & 11 (GP6 & GP8)
 SetPin 4, PWM1A
 SetPin 9,CIN   'input (counting) pin for the high resolution timer.
 SetPin 16,17,I2C   'DA & CLK pins for the BME280
Note:
'  The "SetPin 11,INTL,blip" statement was moved to just before "Main" do loop.
'  but DID NOT fix the problem.

'  The "PWM 1,10000,50" statement was then moved to just before "Main" do loop.
'  and DID fix the problem.


'=============================================================
' Main - modified as above and now working correctly.
'=============================================================
 CLS
 RTC gettime
 Pause 100
 PWM 1,10000,50 'PWM1A pin 4 out to high resol'n timer on counting pin 9 (GP6)
 drawgrids
 Blit read #1,MM.HRes-90,60,60,200   'store the blank scrolling area of the screen.
 bme280_init           'must be run before pressure or humidity
 SetTick 30000,BME     'read presuure every 30 secs.
 SetPin 11,INTL,blip   'interrupt receive pin for data out (DO) of the 433MHz module.
 Print
 Print "BME`C  BME%RH  BMEHg  Ch1`C Ch1%RH Ch2`C Ch2%RH"
 Do
 Loop
'---------------------------------------------

I couldn't see anything in the manual about this being something to watch out for but it might be a good idea to mention it.

Greg