Hi all, I'm trying to output a single character to Teraterm using a pic16f690 and a max232. I have used the following code to output the letter 'C'.
When I probed the input and output to the max232 I think I got what I expected. For the letter 'C', the byte is 11000010.
The attached waveform shows this. I have labelled the start and stop bits as 0* and 1*. Apologies for the order of the byte.
Looking at Teraterm, the terminal is giving garbage symbols and not 'C'.
Anyone have any experience with this?
Thanks in advance.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <pic16f690.h>
#include <xc.h>
#pragma config WDTE = OFF
#pragma config PWRTE = OFF
void main()
{
OSCCON = 0b01111000; //internal 8MHz oscillator
BAUDCTLbits.SCKP = 0; //0 = invert data to TX pins //1 = noninvert
BAUDCTLbits.BRG16 = 0; //8 bit baud gen used
BAUDCTLbits.WUE = 0; //Receiver is operating normally
BAUDCTLbits.ABDEN = 1; //0 = auto baud detect disabled //1 = enabled
TXSTAbits.TX9 = 0; //Selects 8 bit transmission
TXSTAbits.TXEN = 1; //Enables transmit
TXSTAbits.SYNC = 0; //Select async mode
TXSTAbits.SENDB = 0; //0 = sync break complete 1 = send break on next TX
TXSTAbits.BRGH = 0; //Low baud rate speed
TXSTAbits.TX9D = 0; //only for 9 bit transmission
RCSTAbits.SPEN = 1; //Enables serial port pins TX and RX
RCSTAbits.RX9 = 0; //Selects 8 bit transmission
RCSTAbits.CREN = 1; //Enables receiver
while(1)
{
TXREG = 'C';
while(PIR1bits.TXIF == 0);
}
}
The attached waveform shows this. I have labelled the start and stop bits as 0* and 1*. Apologies for the order of the byte.
Looking at Teraterm, the terminal is giving garbage symbols and not 'C'.
Anyone have any experience with this?
Thanks in advance.
Attachments
-
90.9 KB Views: 13