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

RDA1 not firing - 2 UARTS (Solved)

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



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

RDA1 not firing - 2 UARTS (Solved)
PostPosted: Wed Apr 15, 2015 8:58 pm     Reply with quote

Sigh, the learning continues.

Recently got a new dev board and GSM modem:
http://www.mikroe.com/pic/clicker/
Litterally the board and GSM module as shown on the site.

...And it uses a PIC ive never used before... 18F47J53 which took me about 6 hours to get the right Oscillator settings, prior to my post yesterday.


Now, im trying to run my trusty GSM code and have noticed 2 things:

1)
My "Autobaud" feature is not running and seems like
Code:
set_uart_speed(9600,U1);

has no effect on the UART speed. ive looked at it on my Scope and tested with FTDI Boards.

2) The INT_RDA interrupt is not firing at all, even though the modem is responding, as viewed on my scope and piped to a terminal.

I DO have both UART1 and UART2 running simultaneously... one for the modem and the other for debugging. both TX correctly but the ISR is not firing.

Ive enabled GLOBAL and BOTH RDA interrupts.

The code works, as ive been testing it alot lately but now with the processor change things are breaking in the wierdest places.

My compiler version is listed on my signature, obviously the PCH.


My ISR CODE:
Code:
#INT_RDA
void SerialInt1()
{
   Main_Buffer[Main_Buffer_Index]=getchar();               // Gets chars from uart
   Main_Buffer_Index++;                              // Increment counter

      if(Main_Buffer_Index==MAIN_BUFFER_SIZE)
   {
      Main_Buffer_Index=MAIN_BUFFER_SIZE-4;
      //Main_Buffer_Index=0;   // Circle Buffer
      Long_Message=TRUE;
   }
   output_high(PIN_A1);
}


#INT_RDA2
void SerialInt2()
{
}




FUSES:
Code:
#include <18F47J53.h>
#DEVICE PASS_STRINGS=IN_RAM
#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)


Thanks

G
_________________
CCS PCM 5.078 & CCS PCH 5.093


Last edited by Gabriel on Thu Apr 16, 2015 6:43 am; edited 1 time in total
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

Simple test
PostPosted: Wed Apr 15, 2015 9:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Apr 15, 2015 9:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 16, 2015 6:41 am     Reply with quote

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