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 CCS Technical Support

Problem in receiving data in isr

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



Joined: 13 Oct 2020
Posts: 3

View user's profile Send private message

Problem in receiving data in isr
PostPosted: Tue Oct 13, 2020 3:28 am     Reply with quote

Sad


Code:

#include <main.h>

char rcv_data;

#INT_RDA
void  RDA_isr(void)
{     
     
     
      rcv_data=getc();
      putc(rcv_data);
     
}

void main()

   
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   printf("welcome");
   while(TRUE)
   {
       
       //printf("%c",rcv_data);
   }

}
//////////////////////////////////////////
my main.h file is like below


#include <16F15344.h>
#device ADC=10

#use delay(internal=32MHz)


#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B5,bits=8)


Last edited by joanto0477 on Tue Oct 13, 2020 3:47 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 3:41 am     Reply with quote

OK. You are not using the UART. So the interrupt will never trigger.

Understand that on this chip the UART is a PPS peripheral.
This means that to use the UART you have to set it up with PPS.
Look at the 'sticky' at the top of the forum about how to use PPS....

Just assigning the pins, in #use, does not automatically setup the PPS.
joanto0477



Joined: 13 Oct 2020
Posts: 3

View user's profile Send private message

receiving uart data
PostPosted: Tue Oct 13, 2020 3:46 am     Reply with quote

do you want me to add these 2 lines?
pls reply fast

#PIN_SELECT U1RX=PIN_B5
#PIN_SELECT U1TX=PIN_B7
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 3:50 am     Reply with quote

You want:

Code:

#PIN_SELECT U1RX=PIN_B5
#PIN_SELECT U1TX=PIN_B7


#use rs232(UART1, baud=9600,parity=N, bits=8)


I've edited your original post so it shows the code correctly

Using the 'UARTx' designation, _forces_ the compiler to select the
hardware UART, and provided PPS is setup, this then uses the
selected pins.
joanto0477



Joined: 13 Oct 2020
Posts: 3

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 4:01 am     Reply with quote

thank you so much Ttelmah
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Oct 13, 2020 4:29 am     Reply with quote

As Mr. T points out PICs with PPS pins, need 'extra' code to configure the PIC. Perhaps we should have a 'PIC program template' Sticky up top to show the basic correct sequence of code that all could use as a basis for their programs. I can see more confusion when newer PICs have even more 'features', where startup sequence is important.

Jay
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