Serial is back to working

After a few days of testing and fooling I have got the serial channel working again.

The main problem I found was that during the hiatus I had forgotten the processor clock speed I was using! This made calculating the coorect number to use for the baud rate generator difficult.

In the end, I made some measurements and applied some logical thinking to figure out the processor speed and proceeded from there. I first ensured that the uC was sending data whatever speed the current parameters resulted in and made it output streams of 0x55 which generates alternate bits off and on, starting with off. This makes the start and stop bits easy to see on the scope, the stop bit is the widest high pulse and the start bit is the next "high" after it. Between the start and stop bits there is a pulse train of off and on bits. By measuring the time of one of these states, you can find out the 'bit time' and from that determine the 'byte time' the reciprocal of this is the baudrate.

By flipping the equation in the datasheet around you can approximately derive the clock frequency from the baudrate and the value of BRG (it'll be off because of the baudrate error). I did this and came up with approximately 80MHz, which sounds right. I then used 80Mhz to derive the BRG needed for 9600 baud. Plugged that into the code, ran it and remeasured the bit time to confirm. Then I attached it via the FTDI module to a PC, and got the output on the PC I was expecting.

So now serial is working. Time to get the ADC working.

Subject: