|
|
View previous topic :: View next topic |
Author |
Message |
kmp84
Joined: 02 Feb 2010 Posts: 363
|
INTERRUPT-ON-CHANGE |
Posted: Sun Jul 03, 2016 2:36 am |
|
|
Hello,
Can be used interrupt on change for detect data received for software uart on PIC16F1459? In the datasheet says :"Any individual port pin, or
combination of port pins, can be configured to generate
an interrupt PORTA and PORTB 4-7", but in CCS C ver.5.045 only has #int_RA and #int_RB. PS.(INT port is busy with another function!)
Thanks before! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19602
|
|
Posted: Sun Jul 03, 2016 3:25 am |
|
|
The interrupt can _trigger_ on any individual pin, but there is only one interrupt generated for each port.
So there is only INT_RA for port A, and INT_RB for port B.
What you can do is specify which pins this is to trigger 'on', and which edge is to be used.
So:
Code: |
enable_interrupts(INT_RA4_H2L); //enables INT_RA on A4 falling
enable_interrupts(GLOBAL);
|
Then INT_RA will be called on a falling edge on RA4 _only_.
These can be OR'ed.
enable_interrupts(INT_RA4 | INT_RA5);
will trigger either RA4, or RA5 changing.
Remember you must read the port in the interrupt handler, and you need to clear the IOCAF (or BF) flags yourself (either by direct access to these bits or using the clear_interrupt command). |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 363
|
|
Posted: Sun Jul 03, 2016 9:31 am |
|
|
Hello Mr.Ttelmah,
Maybe it should be:
Code: |
#include <16F1459.h>
#fuses NOPROTECT,MCLR,PUT,NOWDT
#use delay(int=8MHz, clock=8MHz, act=USB)
#use rs232(baud=9600, xmit=PIN_A5, rcv=PIN_A4, enable=PIN_C4 ,errors)
byte c=0;
#INT_RA //service software recive byte
void sw_rx_isr(){
clear_interrupt(INT_RA);
c=getc();
}
void main(){
printf("\n\r Print from rs485 stream ");
enable_interrupts(INT_RA4_H2L); //enables INT_RA on A4 falling
enable_interrupts(GLOBAL); // ebable global ISR
for(;;){
if(c!=0){
putc(c);
c = 0;
}
}
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|