AVR: JS16 debug firmware works on UART and BDM pins!
AVR: JS16 debug firmware works on UART and BDM pins!

Before there was code to run it from the UART pins, which are
conveniently next to each other, but it never worked!

The problem: when setting up the port pins I used a sequence of two bclr
(read-modify-write) instructions on the port register. What happens in
this case, esp if you are trying to preset some values *before* turning
the pin into an output, is the second bclr instruction doesn't read the
0 bit you wrote in previously; instead it reads the (probably floating,
or maybe pulled-up) pin and gets a 1 instead.

The only way to reliably set two bits to zero in the port output
register - without changing the state of the pins! - is to read the port
data register, mask and set/reset the bits you care about, and then
write it back out again.

Doing this caused the IIC debug over the UART pins to work fine.

nickhen/muforth,nickhen/muforth