View previous topic :: View next topic |
Author |
Message |
joanto0477
Joined: 13 Oct 2020 Posts: 3
|
Problem in receiving data in isr |
Posted: Tue Oct 13, 2020 3:28 am |
|
|
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
|
|
Posted: Tue Oct 13, 2020 3:41 am |
|
|
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
|
receiving uart data |
Posted: Tue Oct 13, 2020 3:46 am |
|
|
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
|
|
Posted: Tue Oct 13, 2020 3:50 am |
|
|
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
|
|
Posted: Tue Oct 13, 2020 4:01 am |
|
|
thank you so much Ttelmah |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Oct 13, 2020 4:29 am |
|
|
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 |
|
|
|