|
|
View previous topic :: View next topic |
Author |
Message |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
Simple test |
Posted: Wed Apr 15, 2015 9:51 pm |
|
|
Ran a simple test like this:
RDA2 does fire but not RDA1
Ive been reading pretty much any thread that references RDA, with no usable suggetions.
Code: | #include <18F47J53.h>
#fuses NOWDT,NODSWDT
#fuses NOXINST
#fuses NODEBUG
#fuses NOPROTECT
#fuses HSPLL,PLLEN,NOIESO,NOFCMEN
#fuses PLL4 //set usb pll clock to 4MHz (from 16Mhz input)
#fuses NOCPUDIV //set cpu clock to 48MHz
#use delay(clock=48MHz)
#pin_select U2TX=PIN_C2
#pin_select U2RX=PIN_C1
#use rs232(UART1,baud=9600, xmit=PIN_D6, rcv=PIN_D5, ERRORS,STREAM=U1)
#use rs232(UART2,baud=9600, xmit=PIN_C2, rcv=PIN_C1, ERRORS,STREAM=lcd_putc)
#INT_RDA
void RDA_ISR();
#INT_RDA2
void RDA_ISR2();
char a;
void main()
{
setup_comparator(NC_NC_NC_NC);
setup_vref(VREF_OFF);
setup_adc_ports(NO_ANALOGS);
enable_interrupts(INT_RDA); // remote Rx 232 port
enable_interrupts(INT_RDA2); // remote Rx 485 port
enable_interrupts(GLOBAL);
while(1)
{
fprintf(lcd_putc,"TU TIA ES PUTA U2\r\n");
fprintf(U1,"AT\r");
delay_ms(2000);
}
}
#INT_RDA
void RDA_ISR()
{
a=fgetc(U1);
output_high(PIN_A0);
}
#INT_RDA2
void RDA_ISR2()
{
a=fgetc(lcd_putc);
output_high(PIN_A1);
} |
_________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 15, 2015 9:54 pm |
|
|
You have UART1 placed on pins D6 and D5, but you can't relocate
the pins for hardware UART1 on this PIC. It's not allowed:
Quote: |
#use rs232(UART1,baud=9600, xmit=PIN_D6, rcv=PIN_D5, ERRORS,STREAM=U1)
|
If you use those pins, the compiler will create a software UART, so there
will be no RDA interrupt. If you look at the .LST file, and you see
"MOVLW 8" (for the 8 data bits) and you see no reference to RCREG or
TXREG, with only "bit-banging" operations on the port pins, then you know
you are looking at software UART code:
Code: | ...... #use rs232(UART1,baud=9600, xmit=PIN_D6, rcv=PIN_D5, ERRORS,STREAM=U1)
000CA: BSF TRISD.5
000CC: BTFSC PORTD.5
000CE: BRA 00CC
000D0: MOVLW 08 |
The 18F47J53 data sheet says the hardware UART1 can only be on pins
C6 and C7. Only UART2 is relocatable:
Quote: |
The pins of EUSART1 and EUSART2 are multiplexed
with the functions of PORTC (RC6/CCP9/TX1/CK1/RP17
and RC7/CCP10/RX1/DT1/SDO1/RP18) and remapped
(RPn1/TX2/CK2 and RPn2/RX2/DT2), respectively. |
|
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Apr 16, 2015 6:41 am |
|
|
thanks PCM!
I was convinced i had the uart1 pins right and i was assuming a different board design on the uart pin allocation.
I have to say i am pretty disappointed in the board designers choice because as per your observations, both hardware uarts end up in the board's Bus connector. Uart 2 with its remappable pins, is pretty much locked to the connectors pin arrangement. It made sense to me to have the fixed uart, have the fixed connector pins...
Anyways, thanks for your help, you saved me a couple of hours.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
|
|
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
|