CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

INTERRUPT-ON-CHANGE

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

INTERRUPT-ON-CHANGE
PostPosted: Sun Jul 03, 2016 2:36 am     Reply with quote

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: 19359

View user's profile Send private message

PostPosted: Sun Jul 03, 2016 3:25 am     Reply with quote

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: 345

View user's profile Send private message

PostPosted: Sun Jul 03, 2016 9:31 am     Reply with quote

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;
      }
   }
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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