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

Trouble using 16f628a�.

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







Trouble using 16f628a�.
PostPosted: Sat Dec 31, 2005 7:45 am     Reply with quote

Hi all,

Here are my two questions�

1. Can I use TX pin of the USART as I/O if I�m only using it RX pin?? Should I remove xmit pin declaration like this #use rs232(baud=2400, rcv=PIN_B1) to do so??

2. Can I use MLCR/RB5 pin as I/O(source or sink current to drive LED)�..if yes, then how do I reset the uC??

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 31, 2005 12:32 pm     Reply with quote

Quote:

1. Can I use TX pin of the USART as I/O if I�m only using it RX pin??
Should I remove xmit pin declaration like this #use rs232(baud=2400,
rcv=PIN_B1) to do so??

If you do that, the compiler will make a software UART on Pin B1.
You can't have one pin as a hardware UART pin and the other pin
(Pin B2) as an i/o pin. This is due to a hardware limitation of the PIC.
The PIC is not as flexible as we would like it to be.

So if you want a hardware UART, you must declare both pins in the
#use rs232() statement. Example for 16F628A:
#use rs232(baud=2400, xmit=PIN_B2, rcv=PIN_B1, ERRORS)


Quote:

2. Can I use MLCR/RB5 pin as I/O(source or sink current to drive LED)�..if yes, then how do I reset the uC??

In the 16F628A, in the Configuration bits section (in Special Features of
the CPU), it says if you disable MCLR, then:
Quote:
0 = RA5/MCLR pin function is digital Input, MCLR internally tied to VDD

I've done this with a 16F628 by using the NOMCLR fuse setting with CCS
and it still resets properly. You just can't reset it with some external
circuit (such as a pushbutton). But you don't normally do that, anyway.

If you're using a high voltage programmer, such as any of the ICD or
ICD2 units, as well as Mach-X, Warp13a, etc., then they will put about
13 volts on the MCLR pin during programming. Whatever circuit you've
attached to the MCLR pin must be isolated from the Vpp voltage which
is applied during programming. You will need to design a circuit to
do this. This restriction doesn't apply if you're using a Low Voltage
programmer (usually homebuilt).
Ken
Guest







PostPosted: Sat Dec 31, 2005 2:56 pm     Reply with quote

Hi PCM programmer,

Thanks a lot...I appreciate your help....

So far I've been using
#use rs232(baud=2400, xmit=PIN_B2, rcv=PIN_B1), whats the difference between the below one...
#use rs232(baud=2400, xmit=PIN_B2, rcv=PIN_B1, ERRORS)

Thanks again
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 31, 2005 3:32 pm     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=19759&highlight=overrun
Ken
Guest







PostPosted: Sat Dec 31, 2005 11:04 pm     Reply with quote

My last question...

I was going to use PortB to drive 7 segment display....but since TX pin of the USART is not going to set free, I will use some pin of PortA for software USART!! Can I make MCLR/RB5 pin as RX input??

Another problem...I'm will be using RB0/INT pin as input for external interrupt, at the same time I will be sending data for 7 segment display using output_b() function, how can I make it work beacuse outport_b() will send a whole byte of data so RB0/INT pin will become output, which I really don't want!!

Thanks
Ttelmah
Guest







PostPosted: Sun Jan 01, 2006 3:27 am     Reply with quote

This is down to TRIS.
In CCS, there are three operating 'modes' for tris control. The default (standard_io), has the pins change direction, when accessed. If you output a byte, the tris for the whole register gets set. However you can take control of the tris register yourself. If you select #use fixed_io(b_outputs=PIN_B1,PIN_B2,PIN_B3,PIN_B4,PIN_B5,PIN_B6,PIN_B7)
Then the tris BITS are cleared for the top seven bits, and the bottom bit is set, making this pin an input. You can then output a byte on the port, and only the top seven bits of the byte, will actually be output, leaving B0, to operate as an input. You can do the same, with #use fast_io(b), and then setting tris, with set_tris_b(0b00000001);

Best Wishes
Ken
Guest







PostPosted: Sun Jan 01, 2006 4:51 am     Reply with quote

Thanks...what about my first question.

Regards
Ttelmah
Guest







PostPosted: Sun Jan 01, 2006 6:29 am     Reply with quote

On the UART, declare a normal #use RS232 statement, with both pins declared. Otherwise the software UART will be used. You can then use the TX pin _as an input_, by changing the TRIS for this pin to '1' (this overrides the peripheral use of the pin). Alternatively, turn off the transmit 'side' of the UART, by clearing the TXEN bit, and you can then use the bit as I/O.

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