Serial Helper

Whenever you change clock divisor or speed on your chip, or want to try a new serial baud rate, you need to recalculate (or determine experimentally) your b value for the bit delay. Instead, use this program!

bdetect.py
bdetect.asm

The assembly file is meant for a tiny13 which has two way serial communications (it will run on your echo board, if you have one - you probably need to change the pin assignment of rxpin, txpin at the top to match your board). You can use such a board to determine the b value, even if your final board only has one way communication. The basic idea is that you program your chip with bdetect.asm, run bdetect.py, wait 30 seconds or so, and it will print out the correct "b" value for the bit delay. Make sure and modify bdetect.asm to set the clock divisor and speed that you want to use in your own program, and modify bdetecy.py to use the desired baud rate and serial port.

It works by trying a range of b values. At the top you will see bdetect.asm defines minB and maxB. Starting with b=minB, it tries every value of b for the bitdelay until it successfully receives a 'V' over the serial port. This is where the bdetect.py comes in.

bdetect.py is a python program that keeps sending out 'V' over serial. It is also constantly listening. Whenever the chip sucessfully receives a 'V' (indicating that the bitdelay is correct), it goes into a loop printing that b value back to the computer over serial. bdetect.py prints out that b value, and you can now use that b value in your own program for serial communication. (You might want to run it a couple times to make sure its not an error)


edit