I have a problem with my code. I need to configure the timer 1 of my pic (PIC24F16KA102) to make a interruption each second, but I can't achieve it.
This is my example code
Code: Select all
program Temporizador
' Declarations section
dim willow as byte
sub procedure Timer1Int() iv IVT_ADDR_T1INTERRUPT
PR1 = 0xF0C1
LATA.1 = not LATA.1 ' Invert PORTB
Inc(willow)
if (willow mod 10) = 10 then
LATA.0 = not LATA.0
end if
T1IF_bit = 0 ' Clear T1IF
end sub
main:
' Main program
AD1PCFG = 0xFFFF
willow = 0
TRISA = 0 ' Initialize PORTA as output
LATA.0 = 0 ' Set PORTA to zero
LATA.1 = 0 ' Set PORTA to zero
IPC0 = IPC0 or 0x1000 ' Interrupt priority level = 1
TON_bit = 1
TCKPS_1_bit = 0
TCKPS_0_bit = 0
TCS_bit = 0
TGATE_bit = 0
TSYNC_bit = 0
'PR1 = 0xFF80
PR1 = 0xF0C1
T1IE_bit = 1
T1IP_2_bit = 1
T1IP_1_bit = 1
T1IP_0_bit = 1
LATB.14 = 1
end.
Can somebody help me?
Thanks for all.
Willow