I have been trying to get UART code running on 16F627A.This is my first time with PIC.I got the LED blinking at two different Hz.Hence I confirm that 20 Mhz crystal is set by setting config to 3FA6.I have used 15 pf capacitors.My max232 with USB converter is working fine.But I am not able to get UART working on 16F627A.Please help.
unsigned short i;
void main() {
USART_init(9600); // initialize USART module
// (8 bit, 19200 baud rate, no parity bit...)
while (1) {
if (USART_Data_Ready()) { // if data is received
i = USART_Read(); // read the received data
USART_Write(i); // send data via USART
}
}
}
Code:
config bits :
pwrt = on
mclr = off
hs_osc = on
wdt = on
lvp = off
unsigned short i;
void main() {
USART_init(9600); // initialize USART module
// (8 bit, 19200 baud rate, no parity bit...)
while (1) {
if (USART_Data_Ready()) { // if data is received
i = USART_Read(); // read the received data
USART_Write(i + 1); // send data via USART
}
}
}
Does it still do not work ??? ...
"your" program works fine aboard my EasyPic5 with a '628 ( no 627 home ...)
I dont think it is with this piece of code.I think it might be with the bits (config bits setting) for the 16F627A.
I have set PWRT_ON ,WDT_ON ,HS_OSC,LVP_OFF,MCLR_OFF for 16F627A and at 20 Mhz clock.(By the way I am using 22pf caps with the 20 Mhz xtal).
Just changing the variale "i" to "i+1" may not do the thing.I even checked it in the terminal no characters get echoed back not even stray characters.So what could be the problem.(But I will try as you said if something turns out).
I set WDT=OFF but still the PIC does not echo back.Any idea as to what could be the problem?Does the capacitance values on Max232 change from micro to micro.Max232 circuit is working fine with