Thursday 31 January 2008

1 bit! 1 stupid bit!

Finally! I've discovered what has caused all my pain and suffering the last days. It appears that there's some kind of bug in mikroC, in the Soft uart library. This means that I manually have to send a single 1 after transmitting a byte. Doing this, everything works like a charm! Woohoo! I really love mikroC, but it has a few bugs too many. Still, I always get answers from the developers and it has a lot of built in features I would never ever manage to code myself if I had to write in assembler.

I've tried various speeds. It seems that 38400bps works fine, but at 115200 some bytes are dropped. At 38400bps I'm able to transmit 4800bytes/sec, (a bit lower really, there's some overhead), or about 0.2 milliseconds per byte. It could mean a slight delay from pressing a key to the result is received by the second controller, but I guess I just have to try this out. I could also try to up the speed to, say 57600 and see what happens...

Update: 57600 works fine.
Update: 57600 does not work for receiving data when the receiver runs at 8MHz. I have to try this again when both uC's are on the real board.
Update: To use PORTA, it is necessary to add "ADCON1 = 0x07" to turn off analogue inputs.

No comments: