MAS 863: How to Make (Almost) Anything
Phenomenon: You cannot read out the int or character out correctly.
Reason:
The internal clock is not accurate enough, sometimes you need an oscilloscope for debugging.
In Neil's c code, there is a line in the defintion part to define baud rate. Use 115200 for external clock and 9600 for internal clock:
#define bit_delay_time 8.5 // bit delay for 115200 with overhead
or
#define bit_delay_time 100 // bit delay for 9600 with overhead
Take baud rate = 9600 for example: if baud rate is 9600, that means sending one bit at 1/9600us (104us);
Try to send an integer out (1 int = 2 byte = 16bits), through oscilloscope, you could read out how many us it takes for each bit along x axis.
So if the speed per bit is smaller than 104, that means the speed is faster than expected (1 per 104us), so you want to slow the sending speed by increasing the bit delay time :
#define bit_delay_time 108 // bit delay for 9600 with overhead
It's always safe to define the bit_delay_time a little bigger. There's no common number, you need to do small change each time and try to observe the oscilloscope.
Sending out an "A" at 9600 Baud Rate