|
Forum Index : Microcontroller and PC projects : Checking options at runtime
| Author | Message | ||||
| TrevorH Senior Member Joined: 06/04/2018 Location: United KingdomPosts: 145 |
Hi everyone! Is there anyway to check that an option has been set VERY early in a program before running the meat of the program and if not set giving an early exit without crashing the pic32? Trevor |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1772 |
Yes, I guess a CFunction would easily do that. From CFunctions.h //The Option structure struct option_s { char Autorun; char Tab; char Invert; char Listcase; char Height; char Width; int PIN; int Baudrate; int ColourCode; // display related char DISPLAY_TYPE; char DISPLAY_ORIENTATION; // touch related char TOUCH_CS; char TOUCH_IRQ; char TOUCH_SWAPXY; int TOUCH_XZERO; int TOUCH_YZERO; float TOUCH_XSCALE; float TOUCH_YSCALE; // for the SPI LCDs char LCD_CD; char LCD_CS; char LCD_Reset; // Note the next options are only applicable to the MM+ char SerialCon; char SDCARD_CS; char SD_CD; char SD_WP; char DISPLAY_BL; char DISPLAY_CONSOLE; char DefaultFont; char KeyboardConfig; char TOUCH_Click; // To enable older CFunctions to run any new options *MUST* be added at the end of the list But I can't do that at this time. Regards Michael ‚My name is Ozymandias, king of kings Look on my works, ye Mighty, and despair!‘ Nothing beside remains. Round the decay Of that colossal wreck, boundless and bare The lone and ... |
||||
| TrevorH Senior Member Joined: 06/04/2018 Location: United KingdomPosts: 145 |
Thankyou for your reply, but I don't understand what you are telling me. The problem I have is:- my program uses the RTC on an E100 board, if I run the program without setting the RTC options, it crashes the PIC32. This forces me to do the multiple !!!!! thing to recover. I would like to trap the fact that the RTC options are Not set BEFORE I run any more code. Trevor. |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1772 |
Upps, I guess there are no Cfunctions for the E100 (MMX?) possible. Maybe Geoff or Peter have an idea? I am Sorry! ‚My name is Ozymandias, king of kings Look on my works, ye Mighty, and despair!‘ Nothing beside remains. Round the decay Of that colossal wreck, boundless and bare The lone and ... |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11882 |
E100 is MM+ so no issue with cfunctions |
||||
| PicFan Senior Member Joined: 18/03/2014 Location: AustriaPosts: 133 |
Maybe is this a solution ? ON ERROR SKIP RTC GETTIME IF (MM.ERRNO <> 0) THEN PRINT "NO RTC OPTION" END ENDIF |
||||
| TrevorH Senior Member Joined: 06/04/2018 Location: United KingdomPosts: 145 |
I think by running a RTC command is what is crashing the PIC when RTC options NOT set, but will check this out. I was wondering if there is a way of checking which options are set or not Before running device dependant code. @twofingers I am running a CFunction to enable a CPLD TFT screen already Trevor. |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1772 |
Trevor, I fear there is no access (not yet) to the RTC options. I don't have a MM+ so I can't test with it. ‚My name is Ozymandias, king of kings Look on my works, ye Mighty, and despair!‘ Nothing beside remains. Round the decay Of that colossal wreck, boundless and bare The lone and ... |
||||
CircuitGizmos![]() Guru Joined: 08/09/2011 Location: United StatesPosts: 1427 |
I test for the RTC address having a device first before doing an RTC GETTIME. I2C open 100, 1000 ' I2C enable at 100kHz with 1000ms time out I2C read &H68, 0, 1, temp ' 3231 I2C address IF MM.I2C = 0 Then RTC GETTIME EndIf I2C close Micromites and Maximites! - Beginning Maximite |
||||
| TrevorH Senior Member Joined: 06/04/2018 Location: United KingdomPosts: 145 |
@CircuitGizmos . Thanks for that I will give it a whirl. Trevor |
||||
| erbp Senior Member Joined: 03/05/2016 Location: AustraliaPosts: 195 |
I don't know if the following will help, but this is what I use to detect whether the RTC module is present or not on a MX170 which doesn't have an OPTION RTC … command. SETPin Pin_Brake, Off 'release Pin 18 SetPin Pin_Reverse, Off 'release Pin 17 Pause 50 I2C Open 100, 200 'Open the I2C communication session Pause 100 On Error Skip 1 RTC GetTime 'Set MM Date & Time from RTC module via I2C If MM.ERRNO <> 0 then 'RTC not present (or failed to communicate) - Reset RTC_Flag RTC_Flag = 0 etc. etc. In this case I am even sharing the I2C pins with other functions and release them before opening the I2C connection and attempting to get the date/time from the RTC module. I have NOT tried this approach on an E100 using the OPTION RTC … command. Phil. |
||||
| robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2552 |
on the face of it, this behaviour sounds like a bug in the mmbasic firmware. can peter or goeff comment? cheers, rob :-) |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3368 |
If you do not set the RTC option the RTC GETTIME command will try to use the standard I2C interface and if it cannot find the rtc it will give a message "RTC not responding". It will not cause the PIC32 to crash. I don't know what is going on here but it is not the RTC command. Geoff Geoff Graham - http://geoffg.net |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |