Author Topic: cts and rts  (Read 8976 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
cts and rts
« on: September 08, 2008, 02:33:46 PM »
Hi Mark,
  I am using the CTS and RTS on UART1 (com2) as digital pins, but whatever I do it doesnt make any difference. After the serial port gets setup, without hardware handshake , I then do the following:
 
 PUBPAR=0x5; //set tx and rx as primary functions and cts/rts as io
 DDRUB=0x4;  //set rts as output,cts as input
 PORTUB=0;//set rts pin to 0.

at this stage, I check the voltage level of the rts pin, and its high.
When I display the value of PORTUB, I get 4 indicating rts pin is high.
If I apply 3.3v to the cts pin, and also display PORTUB, I still get 4.

Any ideas what I am doing wrong? I have checked the pins and all are correct.

Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3237
    • View Profile
    • uTasker
Re: cts and rts
« Reply #1 on: September 09, 2008, 12:08:26 AM »
Hi Neil

If it is a problem reading CTS then you must use the register PORTIN_SETUB to do this and not PORTUB - PORTUB holds the output state, whereas PORTIN_SETUB contains the present pin state, which is what you need when using as input.
I don't see any problem with the RTS output control - you are configuring as GPIO, as output and driving 0. Writing PORTUB = 0x04 should then set it high.

I think that I have understood that you haven't set PORTUB to 0x04 but you are reading it back. This I can't explain - but check that some other part of the code is really not setting it. When stepping with the debugger check that the instructions have really completed when you do your test - step a few instructions further to be sure; verify the value of PORTUB before your configuration and then afterwards.

regards

Mark