leojma
Joined: 25 Feb 2013 Posts: 6
|
interruption rb0 Pic 16f877a |
Posted: Tue May 21, 2013 6:21 pm |
|
|
Hi my problem is that I can do alone interrupt the every 10 sec ... if time is less not interrupted, this is a test program to learn to use the interruption but I can not interrupt .... only every 10 sec.
Code: |
#if defined(__PCM__)
//#fuses HS,NOWDT,NOPROTECT,NOLVP
#include <16f877a.h>
#use delay (clock = 4 M) //Reloj de 4 Megahertz
#include <stdlib.h>
#use RS232 (baud=9600, bits =8, parity= N, xmit= pin_c6, rcv=pin_c7)// declaracion RS232
#use fast_io(b)
#fuses HS,NOWDT,NOPUT,NOPROTECT
int cont=0;
#int_EXT
void EXT_isr(void)
{
putchar(120);
putchar(121);
}
void main() {
enable_interrupts(INT_EXT);
ext_int_edge(L_TO_H); //
enable_interrupts(GLOBAL);
set_tris_b(0x01);
while (true)
{
printf("%u",cont);
delay_ms(1000);
cont=cont+1;
}
}
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed May 22, 2013 1:38 pm |
|
|
1- don't do putc() in the ISR - it is asking for trouble.
set a flag and do the putc() in MAIN
2- unless you read port_B before leaving the interrupt - the ISR will never clear after first call
3- set_tris_B() may be causing some grief as well, in a non #FASTIO environment
4- add ,ERRORS to your #use rs232
5- this is not a CCS issue so much as it is a "read the datatsheet"
kind of problem.
There may be other problems but this ought to get you started |
|