View previous topic :: View next topic |
Author |
Message |
filjoa
Joined: 04 May 2008 Posts: 260
|
timer0 problem on 12F683 |
Posted: Tue Aug 03, 2010 5:38 pm |
|
|
hi
I try use timer0 on PIC12F683 but when I use timer0 I cant use other interrupts..
For example, my code if I remove timer0 function my interrupt int_ra3 work fine, if I use code like this, program break on enable_interrupts(INT_RA3)...
Quote: |
#include <12F683.h>
#FUSES NOWDT, INTRC_IO, NOCPD, NOPROTECT, NOMCLR, PUT, NOBROWNOUT, NOIESO, NOFCMEN
#use delay(clock=8000000)
int8 n=0;
#int_ra
void int_isr(void)
{
disable_interrupts(GLOBAL);
disable_interrupts(INT_RA3);
reset_cpu();
}
#int_TIMER0
void TIMER0_isr(void)
{
if (n>=7) n=0;
n=n+1;
}
void main()
{
int8 i,aux=0,aux2=0;
int16 time;
enable_interrupts(GLOBAL);
disable_interrupts(INT_RA3);
enable_interrupts(INT_TIMER0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
while(input(PIN_A3)==1);
do {
aux=n;
if (input(PIN_A3) == 1) aux2=1;
} while ((aux2 != 1));
time=200;
for (i=0;i<=4;i++)
{
if (i>=2) time=time+90;
output_a(0x01);
output_high(PIN_A5);
delay_ms(time);
output_a(0x02);
output_low(PIN_A5);
delay_ms(time);
output_a(0x03);
output_high(PIN_A5);
delay_ms(time);
output_a(0x06);
output_low(PIN_A5);
delay_ms(time);
output_a(0x07);
output_high(PIN_A5);
delay_ms(time);
output_a(0x16);
output_low(PIN_A5);
delay_ms(time);
}
switch (aux)
{
case 1 : output_a(0x01);
break;
case 2 : output_a(0x02);
break;
case 3 : output_a(0x03);
break;
case 4 : output_a(0x06);
break;
case 5 : output_a(0x07);
break;
case 6 : output_a(0x16);
break;
}
disable_interrupts(GLOBAL);
disable_interrupts(INT_TIMER0);
clear_interrupt(INT_RA3);
enable_interrupts(GLOBAL);
ext_int_edge(H_TO_L);
enable_interrupts(INT_RA3);
delay_ms(10000);
output_a(0x00);
output_low(PIN_A5);
SLEEP();
}
|
Program stop work when I have bold... someone know a solution to enable interrupt INT_RA3?
Best regards |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Wed Aug 04, 2010 1:53 pm |
|
|
hi
some one know if I have an error on my code?
best regards |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Sat Aug 07, 2010 6:21 am |
|
|
this problem can not be a bug in CCS? |
|
|
rockuup
Joined: 07 Aug 2010 Posts: 4
|
|
Posted: Sat Aug 07, 2010 8:07 am |
|
|
I'm newbie but I think PIN_A3 not support edge detect interrupt. I think only PIN_RA2 is support this |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Sat Aug 07, 2010 11:09 am |
|
|
Hi
thanks for your opinion but it support edge detect interrupt, because all work fine if I dont have "enable_interrupts(INT_TIMER0);"
when I dont use "enable_interrupts(INT_TIMER0);" I can enable and disable disable_interrupts(INT_RA3);
I think with the problem stay on INT_TIMER0 but I don't know where... :s |
|
|
|