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 XMIT and RCV?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

UART XMIT and RCV?
PostPosted: Fri Oct 20, 2006 8:10 am     Reply with quote

Hi All

I would like to use the hardware UART for the RCV.
I am using the XMIT hardware pin for something else, so I cannot use it.

I have tried to specify the hardware pin for the RCV and a different pin for the XMIT, but then the RCV interrupt did not work.

Can someone please tell me how to do this? (i.e. have the RCV pin in hardware, while the XMIT pin software driven)?

(Can I simply not use the XMIT pin?)

Thank you
a.
Ttelmah
Guest







PostPosted: Fri Oct 20, 2006 9:51 am     Reply with quote

Specify both pins in the #use RS232 setup.
Then just use the transmit pin for your other code.
The 'use' directive, _must_ see both hardware pins, or the hardware UART will not be selected. However once selected, the 'output' code itself, does not get generated, unless you actually 'putc' something to the hardware port, and you can override the tris settings, allowing you to then talk to the pin as normal.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Fri Oct 20, 2006 10:22 am     Reply with quote

Hi Ttelmah

Thank you for your reply.

I have set the UART to the hardware pins and it works "fine"- I do get UART interrupts which is great.

However, I use the XMIT pin for something else as well. What I find is that even if I do not use printf, I still get the pin being H. (I do not know if its H all the time, but its used to drive some LEDs and they appear on constatnly- I need them to go H/L periodically).

Any suggestions that you might have will be greately appreciate.
All the best
a.
Ttelmah
Guest







PostPosted: Fri Oct 20, 2006 2:56 pm     Reply with quote

What chip?.
Unfortunately, the way that TRIS behaves with relation to enabling the UART, varies between PICs. On most, if you do an output to the pin, it'll override the UART output. However on some, you have to turn of the transmit component in the UART.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Fri Oct 20, 2006 11:11 pm     Reply with quote

Hi Ttelmah

Thank you. Please can you tell me how to be turn on only the RCV portion of the UART (XMIT declared but the pin to be used for something else).

My chip is: PIC16F628A.

I appreciate your help
a
Ttelmah
Guest







PostPosted: Sat Oct 21, 2006 2:14 am     Reply with quote

The 628, should behave normally. It requires TRIS B.2, to be set high, to run as the UART, so as soon as you perform an 'output' instruction on this pin (which will set this bit low), or simply set this bit low with the TRIS statement, the UART should be deselected. However you can disable the transmit part of the UART yourself, with:
Code:

#BIT TXEN=0x98.5

//Then in your initialisation code:
TXEN=0;
//Will disable the transmit part of the UART, while leaving the receive
//enabled.


Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Mon Oct 23, 2006 2:15 am     Reply with quote

Hi Ttelmah

Thank you for your response.

I have the following code pieces:

Code:

#use rs232(baud=19200, XMIT=PIN_B2, RCV=PIN_B1, ERRORS)
#byte port_b=6
#bit    txen   =0x98.5

.........

main(){


txen = 0;
set_tris_b(0B00000010);


I do get RS232 interrupts- this is great (RCV works).

However, this sets the XMIT pin (B2) H all the time- I have checked this with an O-Scope.
Can you please tell me what I am doing wrong?

Thank you
a.
Ttelmah
Guest







PostPosted: Mon Oct 23, 2006 6:44 am     Reply with quote

Just do 'output_low(PIN_B2)'. This will set the tris automatically, and drive the pin low.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Tue Oct 24, 2006 8:37 am     Reply with quote

Hi Ttelmah

I have tried to do the following:

Code:

#include <16F628A.h>
#fuses HS, PROTECT, NOWDT, NOLVP, PUT
#use delay(clock=4000000)
#use rs232(baud=19200, xmit=PIN_B2, rcv=PIN_B1,ERRORS)

#byte port_b=6
#bit txen= 0X98.5
main(){
     set_tris_b(0B00000010);
     port_b=0;
     txen=0;

     output_low(PIN_B2);
     while(true){
     }
}


and the OScope shows that pin_b2 is H all the time!!! (it should be L-right?)
can you please tell me what I am doing wrong?

Thank you for all your help.
a.
Ttelmah
Guest







PostPosted: Tue Oct 24, 2006 10:44 am     Reply with quote

I'd say 'have you got something connected to the pin, stopping it going low'...
Have just tried this code, in a 16F628A, and the pin is low.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Wed Oct 25, 2006 9:36 am     Reply with quote

Hi Ttelmah

I have disconnected the PIC16F628A, and put PIN_B2 into Oscope, with the code above, and I once again get a H on it.

I must be doing something wrong. Any suggestions that you might have will be greately appreciated.

Thank you for all your help.
a.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 25, 2006 11:19 am     Reply with quote

Post your compiler version and I'll test it.
GUEST
Guest







PostPosted: Thu Oct 26, 2006 1:43 am     Reply with quote

i have same problem and my compiler version is:

pch :3.200
pcm:3.200
pcb :3.200

Thank you for all your help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 26, 2006 2:12 am     Reply with quote

Does "Guest" == Arrow ?

Vs. 3.200 is the first version after CCS made some changes to the
compiler. Here is just part of the list of bug fixes that they did soon
after releasing it.

Quote:

3.202 A problem with the definition of external ROM is now fixed
3.202 The extra NOP FFFF inserted for some chips is now removed by default
3.202 An optimization bug dealing with the BSR is fixed in the PIC18
3.202 The <<= and >>= operators on the PIC18 with int32's no longer corrupt memory
3.202 The +P command line option was failing on some systems, this is fixed
3.202 SET_PWMx_DUTY broke in 3.200 is now fixed
3.202 Some reported problems with the Bootloader examples are fixed
3.203 Floating point multiply for PIC18 is now much faster
3.203 A bug in 3.202 accessing bit fields in constant structures is fixed
3.203 Some optimization bugs including one involving & is fixed
3.204 Optimization bug from 2.203 is fixed
3.204 Missing nibble on larger addresses in the LST file is fixed
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Fri Oct 27, 2006 5:07 am     Reply with quote

Hi PCM Programmer

"Guest" != arrow

My CCS compiler is: 3.242, and I still have that mysterious problem.

Can you please help me find a "work around"?

Thank you
a.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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