GCBASIC compile but I do not get the expected 10seconds flash beat
#chip 18f1220,32
#Config LVP = OFF, MCLRE = On, PWRT = On, WDT = off, BOR = Off, OSC = HSPLL
CONFIG1H = b'0111010' 'HS oscillator PLL ENABLED clock frequency =4xFOSC1
Set FSCM = OFF
Set IESO = OFF
Dir PortA.4 OUT
#Define LED PortA.4
#Define LEDon PortA.4 = 0
#Define LEDoff PortA.4 = 1
'Test timer1 10s beat Test ?
Dim TenthSeconds As Word
TenthSeconds= 0
'HSPLL clock pulse frequency (8x4)/4=8MHz
'Divided by 8 by prescaler (PS1_1/8), timer incremented
'at frequency of 1Mhz i.e. every 1 us
'If cleared then timer overflows after 65535 * 1 us = every 65.535ms
Do
Again:
LEDoff
If TenthSeconds < 200 Then Goto again '0,05x200=10s
TenthSeconds = 0 'reset counter
LEDon
Wait 250 ms
LEDoff
Loop
Sub IncCounter
'Timer will overflow after 65.535ms
'We want it to overflow after 50.00 ms so the timer must have a value loaded into it
'Need to load TMR1H and TMR1L with value that they will have after 50ms
'then it must count from 65535-50000 = 15535
Dim TempSet As Word Alias TMR1H,TMR1L
TempSet= 15535
TenthSeconds = TenthSeconds + 1
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Again is not a keyword in the GCBASIC dialect and I very often use labels like Again: Again1: Again2 in my codes.
I tried your code to avoid the Goto again with the same result no Clock on Pin 15 OSC2 , I am looking to run at the speed of 8x4=32Mhz. I am not able to see if GCBASIC handle the HSPLL in the asm file.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
capaction:
CONFIG1H doesn't look to set a valid OSC setting. Let the compiler set the CONFIG registers. An external 8Mhz crystal or resonator is now being used? The 18f1220 is not able to use the intosc with PLL.
Hi capaction,
Like Kent , I think your Config1H is not correct . It has has only 7 bits .
In 18F1220 datasheet , to configure HSPLL , FOSC<3:0> must be set to 0110
"0110 = HS oscillator, PLL enabled (clock frequency = 4 x FOSC1)"
So , if you don't use FSCM and IESO Config1H will be : b'00000110' , not b'0111010'
If it doesn't works again , try another PIC as Kent suggests you .
Regards
GC
PIC 18F1220
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you Kent, I do not have a crystal on my PCB, then I understand I cannot use HSPLL.
I will buy a 10Mhz crystal to test the PIC 1220 at full speed 40Mhz. Is it safe ?
I cannot use the 18f14k22 as you suggested because the socket on my PCB has 18 pins.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
GCBASIC compile but I do not get the expected 10seconds flash beat
#chip 18f1220,32
#Config LVP = OFF, MCLRE = On, PWRT = On, WDT = off, BOR = Off, OSC = HSPLL
CONFIG1H = b'0111010' 'HS oscillator PLL ENABLED clock frequency =4xFOSC1
Set FSCM = OFF
Set IESO = OFF
Dir PortA.4 OUT
#Define LED PortA.4
#Define LEDon PortA.4 = 0
#Define LEDoff PortA.4 = 1
'Test timer1 10s beat Test ?
Dim TenthSeconds As Word
TenthSeconds= 0
'HSPLL clock pulse frequency (8x4)/4=8MHz
'Divided by 8 by prescaler (PS1_1/8), timer incremented
'at frequency of 1Mhz i.e. every 1 us
'If cleared then timer overflows after 65535 * 1 us = every 65.535ms
InitTimer1 OSC,PS1_1/8
ClearTimer 1
StartTimer 1
On Interrupt Timer1Overflow Call IncCounter
Do
Again:
LEDoff
If TenthSeconds < 200 Then Goto again '0,05x200=10s
TenthSeconds = 0 'reset counter
LEDon
Wait 250 ms
LEDoff
Loop
Sub IncCounter
'Timer will overflow after 65.535ms
'We want it to overflow after 50.00 ms so the timer must have a value loaded into it
'Need to load TMR1H and TMR1L with value that they will have after 50ms
'then it must count from 65535-50000 = 15535
Dim TempSet As Word Alias TMR1H,TMR1L
TempSet= 15535
TenthSeconds = TenthSeconds + 1
End Sub
I don't know if you can call a label ( again) in a loop .
But you can try this :
do
If Tenthseconds<200 then
LEDoff
else
LEDon
Wait 250 ms
LEDoff
TenthSeconds = 0 'reset counter
end if
loop
GC
Again is not a keyword in the GCBASIC dialect and I very often use labels like Again: Again1: Again2 in my codes.
I tried your code to avoid the Goto again with the same result no Clock on Pin 15 OSC2 , I am looking to run at the speed of 8x4=32Mhz. I am not able to see if GCBASIC handle the HSPLL in the asm file.
capaction:
CONFIG1H doesn't look to set a valid OSC setting. Let the compiler set the CONFIG registers. An external 8Mhz crystal or resonator is now being used? The 18f1220 is not able to use the intosc with PLL.
For a device with an intosc using PLL, look at the 18fxxk22 series, and revisit previous conversation http://sourceforge.net/projects/gcbasic/forums/forum/596084/topic/4013532
Kent
Hi capaction,
Like Kent , I think your Config1H is not correct . It has has only 7 bits .
In 18F1220 datasheet , to configure HSPLL , FOSC<3:0> must be set to 0110
"0110 = HS oscillator, PLL enabled (clock frequency = 4 x FOSC1)"
So , if you don't use FSCM and IESO Config1H will be : b'00000110' , not b'0111010'
If it doesn't works again , try another PIC as Kent suggests you .
Regards
GC
PIC 18F1220
Thank you Kent, I do not have a crystal on my PCB, then I understand I cannot use HSPLL.
I will buy a 10Mhz crystal to test the PIC 1220 at full speed 40Mhz.
Is it safe ?
I cannot use the 18f14k22 as you suggested because the socket on my PCB has 18 pins.
Another thread closed due to spam bot, I wish the Sourceforge guys would start screening for it soon :(