munromh
- 25th September 2009, 15:41
Having a few problems getting some basic functions to work properly on a 16F684, not sure if I can see the forest through the trees now. Basically I can't get the toggle function to work, works fine if I set a pin to 1 then 0. Also, if I have a SEROUT pin on the same Port as a Pin I'm manually toggling the SEROUT works but the toggle doesn't, move the SEROUT to a different port and all's fine:
'16f684
DEFINE OSC 8 'Oscillator speed in MHz
OSCCON = %01110111 'Page 20
ANSEL = %00000000
TRISA = %00000000
TRISC = %00000000
PortA = %00000000
PortC = %00000000
WPUA = %00000000
CMCON0 = %00000000
ADCON0 = %00000000
ADCON1 = %00000000
Heart_Beat_LED Var portC.1 'Output pin to LED for Heart Beat indication, Low is on.
Heart_Beat_LED = 0
Terminal_TX var PortC.2 'Output pin to the dumb terminal or PC program on port C
Start:
'Uncomment subroutine 1, 2, or 3
'Goto Subroutine_1
'Goto Subroutine_2
'Goto Subroutine_3
goto Start
Subroutine_1: 'This works.
Heart_Beat_LED = 1
Pause 1000
Heart_Beat_LED = 0
Pause 1000
Goto Start
Subroutine_2: 'Pin is "low" and can be seen cycling between 125mV and 75mV on a scope.
'both serial out's seen on terminal.
'If I move the Terminal_TX to PortA it works.
Heart_Beat_LED = 1
serout Terminal_TX,6,["1-Heart_Beat_LED",13,10]
Pause 1000
Heart_Beat_LED = 0
serout Terminal_TX,6,["2-Heart_Beat_LED",13,10]
Pause 1000
Goto Start
Subroutine_3: 'Doesn't work
Toggle Heart_Beat_LED
Pause 1000
Goto Start
'16f684
DEFINE OSC 8 'Oscillator speed in MHz
OSCCON = %01110111 'Page 20
ANSEL = %00000000
TRISA = %00000000
TRISC = %00000000
PortA = %00000000
PortC = %00000000
WPUA = %00000000
CMCON0 = %00000000
ADCON0 = %00000000
ADCON1 = %00000000
Heart_Beat_LED Var portC.1 'Output pin to LED for Heart Beat indication, Low is on.
Heart_Beat_LED = 0
Terminal_TX var PortC.2 'Output pin to the dumb terminal or PC program on port C
Start:
'Uncomment subroutine 1, 2, or 3
'Goto Subroutine_1
'Goto Subroutine_2
'Goto Subroutine_3
goto Start
Subroutine_1: 'This works.
Heart_Beat_LED = 1
Pause 1000
Heart_Beat_LED = 0
Pause 1000
Goto Start
Subroutine_2: 'Pin is "low" and can be seen cycling between 125mV and 75mV on a scope.
'both serial out's seen on terminal.
'If I move the Terminal_TX to PortA it works.
Heart_Beat_LED = 1
serout Terminal_TX,6,["1-Heart_Beat_LED",13,10]
Pause 1000
Heart_Beat_LED = 0
serout Terminal_TX,6,["2-Heart_Beat_LED",13,10]
Pause 1000
Goto Start
Subroutine_3: 'Doesn't work
Toggle Heart_Beat_LED
Pause 1000
Goto Start