hisham.i
Joined: 22 Aug 2010 Posts: 43
|
dspic timer 1 problem |
Posted: Thu May 05, 2011 3:34 am |
|
|
Hello..
Its the first i use timers, and i was testing a program which makes interrupt after timer overflow and send character to serial port.
When i used External clock source for timer configuration the timer is not working while using internal clock source in timer configuration the timer works.
This is the code(am using dspic30f4012):
Code: | #include <30f4012.h>
#device *=16 //16 bits pointer
#fuses XT_PLL8,NOWDT,NOPUT,PR
#device ADC=10
#use delay(clock=80MHZ)
#use rs232(baud=9600,parity=N,xmit=PIN_C13,rcv=PIN_C14,bits=8)
void main()
{
setup_uart(9600);
delay_ms(100);
putc('k');
ENABLE_INTERRUPTS(INTR_GLOBAL );
SETUP_TIMER1(T1_EXTERNAL_SYNC| TMR_DIV_BY_8);
SET_TIMER1(0);
ENABLE_INTERRUPTS(INT_TIMER1);
while(1);
}
#INT_TIMER1
void inter_timer1()
{
putc('h');
SET_TIMER1(0);
} |
What can be done in order for the timer to work with the external clock?
The second question if i used the internal clock for the timer, the whole program will still work on the external oscillator clock right?
Thanks |
|