Clock Speed
Moderators: David Barker, Jerry Messina
Clock Speed
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.
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.
-
- Registered User
- Posts: 29
- Joined: Wed Nov 03, 2010 7:18 pm
- Location: Occupied South (Virginia)
Re: Clock Speed
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
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
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
Re: Clock Speed
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...
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Clock Speed
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')
Anything < 1MHz is evaluating to 'clock = 0' so it blows up and doesn't generate any library code (hence the missing 'SBCDSTD')
Re: Clock Speed
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
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
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Re: Clock Speed
Right now, any 'delayus' or 'delayms' calls will cause a problem with 'clock' settings < 1
I'll have to take a look at that...
I'll have to take a look at that...
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
Re: Clock Speed
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...
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...
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
Re: Clock Speed
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
https://www.sfcompiler.co.uk/wiki/pmwi ... ionHistory