PDA

View Full Version : Serial com - AUSART 16F88 - any samples?



flotulopex
- 2nd September 2006, 13:07
Hello,

I would like to transmit serial data using the integrated AUSART module in PIC16F88. THE PIC is directly connected to the PC.

Each time I start the transmission, the terminal receives some characters (not corresponding to what I send) and the RX counter doesn't stop just as if it would continue to receive datas.

It looks like a transmission speed error; I then tried all possible baudrates from 300 to 28800 bauds -> no improvement.

The datasheet indicates to set the TRISB accordingly. Except I/Os, I couldn't find other settings. Are there any?

Does someone have similar applications examples I could have a look at please?

Here is my code; unfortunately, it doesn't work well.


'PORTB.0 is button (INTCON use)
'PORTB.4 is LED
'PORTB.5 is TX (PIC fixed) connected to PC's SUB-D9 pin 2
'GND connected to PC's SUB-D9 pin 5
'On PC Micro Code Studio's Terminal set to 9600,N,8,1

OSCCON = %01100000 'Internal RC set to 4MHZ
TRISB = %00000101 'PORTB.0 & 2 are Inputs - all others are Outputs
RCSTA = %10000000 'Enable serial port (RB2=RX & RB5=TX)
TXSTA = %00100000 'Enable Transmit Bit
SPBRG = 6 'Set baudrate to 9600

Message var word
Message = 12345

MAIN:
if INTCON.1 = 1 then 'Start prog
INTCON.1 = 0 'Reset INT flag
high PORTB.4 'Led On = transmission start
TXREG = Message
low PORTB.4 'Led Off = transmission end
endif
goto MAIN
end

paul borgmeier
- 2nd September 2006, 14:38
I would like to transmit serial data using the integrated AUSART module in PIC16F88. THE PIC is directly connected to the PC.

[code]...
'On PC Micro Code Studio's Terminal set to 9600,N,8,1
...[code]

The AUSART uses TRUE format only (idles high). You have hyperterminal set for INVERTED (idles low). I believe your options are:

a) use the USART with a level converter like the MAX232 between your pin and the PC.
b) use software inverted serial routines (like serin/serout) instead of the USART - then you can stay directly connected to the PC.

flotulopex
- 2nd September 2006, 15:05
Hello Paul,

I thought that the AUSART module was replacing an external level converter. So it is not the case?

What is a TRUE format?

DynamoBen
- 2nd September 2006, 15:17
No, the AUSART doesn't replace a level converter. Most use the AUSART because it can buffer two bytes and you can utilize interrupts with it.

Paul described it pretty well. True format means that when the lines are not being using they are High. Your computer however lets the lines go low when they are idle.

So your options are a level converter like the max232, debug, or serin/serout and a few resistors.

flotulopex
- 2nd September 2006, 15:22
Thank you.

It's now very clear to me.

This is most of the problems I face with programming the PICs: I don't fully understand the data sheets...

Regards

DynamoBen
- 2nd September 2006, 15:26
Yeah I had that problem too when I started. It takes practice to understand them. I still read a section a few times to make sure my head is wrapped around it before I begin.