Hi friends
I use this code to read from a device with 115200 baud rate and write to other device those data with 9600 bps, but it doesn't change from 115200 to 9600 and sends data with 115200. what should i do to change baud rate just after reading data?
Code:
while(1)
{
U1BRG=15;
U1MODE=0X8400; //ENABLE UART MODULE AND SOME SETTINGS
U1STA=0X8400;
for(i=0;i<5000;i++);
get_frame();
accx = make16(input[2],input[3]);
accy = make16(input[4],input[5]);
accx /= 5;
accy /= 5;
U1BRG=191;
U1MODE=0X8400; //ENABLE UART MODULE AND SOME SETTINGS
U1STA=0X8400;
for(i=0;i<5000;i++);
send(lsb(accx));
send(lsb(accy));
}//end of while(1)
not sure why it does not work! you could try disabling the UART by clearing the UARTEN bit in U1MODE (or writing 0 to U1MODE and U1STA) before changing the baud rate (possibly put a few Nops() after the U1MODE=U1STA=0)? If you read U1BRG after setting it is it the correct value?
if I run teraterm at 115200baud it shows the 115200baud message then rubbish, if I set termterm to 9600baud and reset the board it shows rubbish then the 9600baud message
there is no BRGH bit in 30F2011, i did another settings that you wrote here but still it doesn't change!! i reduced frequency too but problem didn't solve!