AVE...
I'm working on small project that involves PIC16F1827 connected to PC via PL2303HX USB<>UART thingy. PIC is running with internal oscillator set to 4Mhz. But whatever I do, I can't receive anything, but two bytes that are wrong and then framing error. Just after startup I set OSCCON to proper value, but it might not work for some reason. I'm using mikroC for PIC. The important bits:
I'm working on small project that involves PIC16F1827 connected to PC via PL2303HX USB<>UART thingy. PIC is running with internal oscillator set to 4Mhz. But whatever I do, I can't receive anything, but two bytes that are wrong and then framing error. Just after startup I set OSCCON to proper value, but it might not work for some reason. I'm using mikroC for PIC. The important bits:
Code:
volatile unsigned char stats = 0;
sbit confOK at stats.b0;
sbit DMode at stats.b7;
volatile float fConst;
volatile char uarttext;
void config()
//uC configurator
{
OSCCON = 0x6A; //Oscillator configuration
TRISA = 0x00;
PORTA = 0;
TRISB = 0x33;
PORTB = 0;
Dmode = 1; // Set in firmware for now
UART1_Init(2400);
Delay_ms(100);
confOK = 1;
}
void main()
{
if (confOK == 0) config;
fConst = 34,359738368; //firmware defined magic
if (Dmode == 1) //debug routine
{
floatToStr(fConst, uarttext);
UART1_Write_Text("Debug mode 1");
while(0)
{
[...]
UART1_Write_Text(uarttext);
UART1_Write(0x0A);
UART1_Write(0x0D);
UART1_Write(0x3F);
}
}
}