PDA

View Full Version : Serout/Serout2 on pin RC6



Ioannis
- 11th December 2008, 12:08
It is been 2 days now struggling with this simple thing:

Use the hardware USART output with Serout/Serout2 command.

It doesn't do anything! Can anyone please tell me why? On the same pin Hserout works OK.

MCU:16F877, MPASM, PBP2.40

Ioannis

P.S. Of course if the command (serout/serout2) is changed on another pin it works OK as expected.

mackrackit
- 11th December 2008, 12:39
I am sure you do not have the TXSTA register set for enable, but it is the only thing I can think of.

I have used RC6 with SEROUT/2 in the past with this chip and did not have any trouble.

Ioannis
- 11th December 2008, 13:17
Thank pa for the reply. Well, I forgot to mention that I am using the PICDEM2 board with the ICD2 without the debugger. Is it possible that the ICD2 keeps the port for itself? If yes why does the Hserout works OK?

The last rules out the setup case.

How will the TXSTA come in the middle relative to Serout?

Also I tried to pull low the portc.6, but is not possible. So I think it has to do with the ICD2 thing.

Ioannis

mackrackit
- 11th December 2008, 13:31
I was thinking that the TXSTA if enabled would be tying up the pin.

Not sure about the ICD2.

Ioannis
- 11th December 2008, 13:36
I got confussed thinking that ICD2 uses the RC6/RC7 pins. Nop. The poblem I think is that I used the DEFINES on top of the program and the UART is holding the pins for itself. UART has higher priority than TRIS i suppose. I'll try and come back.

Ioannis

Ioannis
- 11th December 2008, 13:54
Yes. This is the problem. When there is a Hserout command inside the program (no matter where, even at the end), the TX pin is engaged by the UART and cannot be controlled.

Now I have to find out how to release it from the UART control.

TXSTA=2 and RCSTA=0 did not help.

What I really want to do is to emulate a 1200 baud trasnmission of one zero (0), like this:

LOW PORTC.6
PAUSEUS 7500
HIGH PORTC.6

That way there is no need to deal with BAUD rate change. If it only worked...

Ioannis

mackrackit
- 11th December 2008, 14:01
Maybe


TXSTA = %00000000

Ioannis
- 11th December 2008, 16:07
It really does not make any difference. I tried that too.

Ioannis

Dave
- 11th December 2008, 17:23
Ioannis, Obviously none of you are reading the data sheets for the processors you are trying to program... Set RCSTA.7 to 0 and the port is all yours...

Dave Purola,
N8NTA

skimask
- 11th December 2008, 18:02
Ioannis, Obviously none of you are reading the data sheets for the processors you are trying to program... Set RCSTA.7 to 0 and the port is all yours...
Dave Purola,
N8NTA

Or are they?
Post #6 above...

TXSTA=2 and RCSTA=0 did not help.

Ioannis
- 11th December 2008, 18:14
Thanks all. It is weird that it will not work setting the SPEN to 0. I did try it and did not get any positive result. If anyone can try it on its own I'd be obliged.

Ioannis

mackrackit
- 11th December 2008, 20:35
Ioannis, Obviously none of you are reading the data sheets for the processors you are trying to program... Set RCSTA.7 to 0 and the port is all yours...


What!!! Read the data sheet!!! That is just asking tooo much :D

Anywho, that is why I suggested
TXSTA = %00000000

being we are dealing with the transmit part/pin..

bit 5 is all that, I thought, needed set to zero.

Ioannis,
When I get home this weekend I am going to play with this.

Ioannis
- 11th December 2008, 21:24
Thanks Dave. It is not in TXSTA but in RCSTA, bit 7 where the UART is enabled/disaled. But as I stated before, once it is enebled and there are even 1 Hserout command somewhere in the program, I cannot gain control of the port pin. May be I got a defective chip, maybe there is a ghost around. I cannot explain it.

Before posting usually the manual/data sheet is really dusted good. In vein...

I will try tomorrow with different system (MCU/PC/Programs).

Ioannis

Ioannis
- 12th December 2008, 11:28
I am a little embarrased. I feel like Goofy. Anyway. The problem was the Decimal/Hexadeciml numbers I got confussed.

Mister-e has involved to this! His utility shows the numbers in Decimal, while the copy variables has a mix of decimal/hex numbers.

All is working OK now. Sorry for the lost time.

Ioannis

P.S. I Attache the test code for On the fly Baud Rate changing.

mackrackit
- 12th December 2008, 19:06
I am a little embarrased. I feel like Goofy.
Me too.

To switch from hardware to software


'# 16F877A
DEFINE OSC 20
X VAR BYTE
START:X = X + 1
HIGH PORTD.2 :PAUSE 250:LOW PORTD.2:PAUSE 250' HEARTBEAT
RCSTA=$90:TXSTA=$24:SPBRG=129:HSEROUT ["HSER ",DEC X,13,10]
PAUSE 250:RCSTA=$0:SEROUT2 PORTC.6,84,["SER ",DEC X,13,10]
GOTO START