Clock Speed

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
raspen
Posts: 9
Joined: Thu Apr 30, 2020 2:28 pm

Clock Speed

Post by raspen » Wed Jun 17, 2020 8:07 pm

I can successfully run my chip 18F25k50 anywhere from 1 to 64 mHz with setting:(clock = 1 to clock = 64), however I want to run slower to save battery life.

It looks like the Include "intOSC.bas" has options for 0.031, 0.25 and 0.5 , but when I choose these speeds (clock = 0.25)
I get 14 assembly errors of _DB_STRCONSTxx.

Here is the top of my code:

Device = 18F25k50 //18F25K50
Clock = 0.25 //
Include "intOSC.bas" // MUST HAVE THIS HERE
Include "Convert.bas"

Any help would be great.

W4GNS
Registered User
Registered User
Posts: 28
Joined: Wed Nov 03, 2010 7:18 pm
Location: Occupied South (Virginia)

Re: Clock Speed

Post by W4GNS » Wed Jun 17, 2020 9:15 pm

Worked fine for me
snipSword.PNG
snipSword.PNG (11.88 KiB) Viewed 273 times
Gary W4GNS

W4GNS
Registered User
Registered User
Posts: 28
Joined: Wed Nov 03, 2010 7:18 pm
Location: Occupied South (Virginia)

Re: Clock Speed

Post by W4GNS » Thu Jun 18, 2020 12:16 am

Maybe also provide the "bottom" of your code.
I was able to create an error code simply by adding a delayms(), different error than yours. So the rest of your code will play a part
Gary W4GNS

User avatar
David Barker
Swordfish Developer
Posts: 1183
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: Clock Speed

Post by David Barker » Thu Jun 18, 2020 9:58 am

Yes, the error seems a little anomalous. We will look into it. However, as W4GNS has pointed out it would help to post some additional code that generates the error in your use case. Thanks...

Jerry Messina
Swordfish Developer
Posts: 1184
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Clock Speed

Post by Jerry Messina » Thu Jun 18, 2020 11:03 am

It looks like it's ignoring any fractional portions of the 'clock' statement when it generates a delay (MHz resolution only).

Anything < 1MHz is evaluating to 'clock = 0' so it blows up and doesn't generate any library code (hence the missing 'SBCDSTD')

raspen
Posts: 9
Joined: Thu Apr 30, 2020 2:28 pm

Re: Clock Speed

Post by raspen » Thu Jun 18, 2020 1:03 pm

Looks like it is related to the DOGM display. Here is part of the code:

Device = 18F25k50 //18F25K50
Clock = 0.25 // 64,16,8,4, 1. 0.031, 0.25, 0.5
Include "intOSC.bas" // MUST HAVE THIS HERE
Include "Convert.bas"

'--------------------------------LCD----------------------------------------------
// LCD configure options...
#option LCD_DOGM = DOGM_163 // 3 line
#option LCD_INTERFACE = 4 // 4 bit data bus
#option LCD_RS = PORTB.4 // RS
#option LCD_EN = PORTB.5 // EN
#option LCD_D0 = PORTB.3 // D4
#option LCD_D1 = PORTB.2 // D5
#option LCD_D2 = PORTB.1 // D6
#option LCD_D3 = PORTB.0 // D7
Include "LcdDogm.bas"
'-----------------------------------ADC-------------------------------------------
Include "ADC.bas"
Function ADInAsVolt() As Word
result = ADC.Read(2) 'PORT A.2
End Function
Dim ADVal As Word
'--------------------------------------------------------------------------------
SetAcqTime(24) 'FOR ADC
SetConvTime(FOSC_2) ' is 2 correct?
'-----------------------------------SPLASH-----------------------------------------
SPLASH:

Dogm.WriteAt(1,1,"line 1 ") ' beginning of line 1
Dogm.WriteAt(2,1, "line 2") ' beginning of line 2
Dogm.WriteAt(3,1, "line 3") ' beginning of line 3
DelayMS(600)
Dogm.Cls() ' clear display

Jerry Messina
Swordfish Developer
Posts: 1184
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Clock Speed

Post by Jerry Messina » Thu Jun 18, 2020 1:35 pm

Right now, any 'delayus' or 'delayms' calls will cause a problem with 'clock' settings < 1

I'll have to take a look at that...

User avatar
David Barker
Swordfish Developer
Posts: 1183
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: Clock Speed

Post by David Barker » Thu Jun 18, 2020 1:46 pm

Jerry is correct. It looks like delayMs() and delayUs() when clock < 1 causes the problem. Note that even if your main code block does not use either of these calls, the LCD module certainly does (for timing). I can confirm that removing all calls to delayXx() negates the issue (please do not do this at home - you will break the modules timings!)

WORKROUND

For now, just work with internal clock = 1.0 or higher. This will enable you to carry on coding and testing until we can patch the problem...

User avatar
David Barker
Swordfish Developer
Posts: 1183
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: Clock Speed

Post by David Barker » Tue Jun 23, 2020 9:13 am

There is a new update available which should fix this problem for you. Just run "check for update" in the IDE "About" box. For more information, see:

https://www.sfcompiler.co.uk/wiki/pmwi ... ionHistory

Post Reply