camerart
- 20th January 2016, 11:07
Hi,
Can anyone help me with a TMR0 question please?
I have a program with the sections below in it:
I need a longer time than TMR0H = 0 TMR0L = 0 allows. So I want to add more TIME into the program, as 'TIME = TIME + 1' If time = 10 then do something.
Also, I'm not sure if I have the TMR0 switching on at the correct time.
Any suggestions welcome.
Camerart.
###############################################
'set up timer 1
T0CON.TMR0ON = 1 'Bit7 = enables timer0
T0CON.T016BIT = 0 'Bit6 = timer0 is configured As A 16-Bit timer/TIME
T0CON.T0CS = 0 'Bit5 = Internal clock (FOSC/4)
T0CON.T0SE = 0 'Bit4 = 0 = Increment on low-to-high transition on T0CKI pin
T0CON.PSA = 0 'Bit3 = Timer0 prescaler is assigned.from prescaler output
T0CON.T0PS2 = 0 'Bit2 = 1:2 Prescale value
T0CON.T0PS1 = 0 'Bit1 = 1:2 Prescale value
T0CON.T0PS0 = 0 'Bit0 = 1:2 Prescale value
#################################################
If INTCON.TMR0IF = 1 Then 'Switches at TMR0 rollover
time = 1 'SIMULATE CHECK
'INTCON.TMR0IF = 0 MOVED
TMR0H = 0 'Watch TMR0 HIGH BYTE not TMR0H>>>>>>>>>>>>>>>>>
TMR0L = 0
Endif
################################################## ##
If poscount = azimval Then
If time = 0 Then
Gosub brake
Goto get_count '[poscnt]
Endif
If time = 1 Then 'added
Gosub brake 'added
time = 0 'added
INTCON.TMR0IF = 0 'added
Goto clr_azim 'Get new angle AZIMVALadded
Endif
Endif
################################################
Can anyone help me with a TMR0 question please?
I have a program with the sections below in it:
I need a longer time than TMR0H = 0 TMR0L = 0 allows. So I want to add more TIME into the program, as 'TIME = TIME + 1' If time = 10 then do something.
Also, I'm not sure if I have the TMR0 switching on at the correct time.
Any suggestions welcome.
Camerart.
###############################################
'set up timer 1
T0CON.TMR0ON = 1 'Bit7 = enables timer0
T0CON.T016BIT = 0 'Bit6 = timer0 is configured As A 16-Bit timer/TIME
T0CON.T0CS = 0 'Bit5 = Internal clock (FOSC/4)
T0CON.T0SE = 0 'Bit4 = 0 = Increment on low-to-high transition on T0CKI pin
T0CON.PSA = 0 'Bit3 = Timer0 prescaler is assigned.from prescaler output
T0CON.T0PS2 = 0 'Bit2 = 1:2 Prescale value
T0CON.T0PS1 = 0 'Bit1 = 1:2 Prescale value
T0CON.T0PS0 = 0 'Bit0 = 1:2 Prescale value
#################################################
If INTCON.TMR0IF = 1 Then 'Switches at TMR0 rollover
time = 1 'SIMULATE CHECK
'INTCON.TMR0IF = 0 MOVED
TMR0H = 0 'Watch TMR0 HIGH BYTE not TMR0H>>>>>>>>>>>>>>>>>
TMR0L = 0
Endif
################################################## ##
If poscount = azimval Then
If time = 0 Then
Gosub brake
Goto get_count '[poscnt]
Endif
If time = 1 Then 'added
Gosub brake 'added
time = 0 'added
INTCON.TMR0IF = 0 'added
Goto clr_azim 'Get new angle AZIMVALadded
Endif
Endif
################################################