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

UART problem on PIC24

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



Joined: 19 Feb 2010
Posts: 8

View user's profile Send private message

UART problem on PIC24
PostPosted: Wed Feb 24, 2010 5:36 am     Reply with quote

Hello,

I'm having problem receiving data with PIC24HJ64GP502, comp. v4.093. I found that the RX pin is always at 0V in idle mode, and not at 3.3V. The problem is on both UART, while no poblem to send data.
Here the testing code.

Code:
#include <24hj64gp502.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOBSS                    //No boot segment
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOWRT                    //Program memory not write protected
#FUSES FRC                      //Internal Fast RC Oscillator
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOPR                     //Pimary oscillaotr disabled
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES WPRES128                 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16                 //Watch Dog Timer PostScalar 1:32768
#FUSES PUT128                   //Power On Reset Timer value 128ms
#FUSES IOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NORSS                    //No secure segment RAM
#FUSES NOSSS                    //No secure segment
#FUSES NOWRTSS                  //Secure segment not write protected
#FUSES NORBS                    //No Boot RAM defined
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOCOE                    //Device will reset into operational mode
#FUSES NOJTAG                   //JTAG disabled
#FUSES ICSP1                    //ICD uses PGC3/PGD3 pins
#FUSES ALTI2C                 //I2C mapped to alternate pins

#use delay(clock=7370000)

#pin_select U1RX=PIN_B10
#pin_select U1TX=PIN_B11
#use rs232(UART1,baud=9600,bits=8, parity=N, stop=1,stream=u1)

#pin_select U2RX=PIN_B5
#pin_select U2TX=PIN_B6
#use rs232(UART2,baud=9600,bits=8, parity=N, stop=1,stream=u2)

char c;

void main()
{   
fprintf(u2,"Start\r\n");
while(TRUE)
   {
   if (kbhit(u1))
      {
      c=fgetc(u1);
      fputc(c,u2);
      }
   }

}
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Feb 24, 2010 6:18 am     Reply with quote

Quote:
I found that the RX pin is always at 0V in idle mode
You mean, it's driven externally to 'H' but sensed as 'L'?. How do you detect it? Do you see a break state at the UART?
raffaele



Joined: 19 Feb 2010
Posts: 8

View user's profile Send private message

PostPosted: Wed Feb 24, 2010 6:31 am     Reply with quote

I had a Max3223 to connect PIC to PC and I noticed no received data on PIC. Then I've disconnected MAx3223 leaving free the pin, with scope I can see 0V. 0V means 1 logic with TTL UART.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Feb 24, 2010 8:55 am     Reply with quote

If you disconnect the MAX3223, the Rx input pin isn't driven. How should it have a different voltage than 0?
raffaele



Joined: 19 Feb 2010
Posts: 8

View user's profile Send private message

PostPosted: Thu Feb 25, 2010 3:12 am     Reply with quote

Usually RX pin are at high voltage level and driven low by TX pin, to confirm this i've checked the RX pin of HW UART of a PIC16F689 leaving it disconnected.
I've tried also to set the inverting bit in the Uart register and it's the same.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Feb 25, 2010 11:22 am     Reply with quote

Quote:
Usually RX pin are at high voltage level and driven low by TX pin

They have a high idle level. Some processors also have fixed pull-up resistors at all or a several I/O pins.
PIC24 hasn't. So the pin floats most likely low.

If I understand right, your real problem is no receive action of the UART. The test with Rx level and disconnected MAX
chip is meaningless in this regard, I think. If the level is 0V with MAX3232 connected, you have a problem with the MAX chip,
not the PIC24. Check, why the MAX chip isn't driving out high level in idle state.
raffaele



Joined: 19 Feb 2010
Posts: 8

View user's profile Send private message

PostPosted: Fri Feb 26, 2010 5:01 am     Reply with quote

Thank you, it's working connected a 3.3V serial device, thank you for your advice.
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