I seem to have an odd problem with the TWI bus on the AT90CAN128 which I haven't seen with the same program running (with register address changes) on the Mega128.
I'm using the TWI bus for a very simple purpose: to write a setting to a Digipot chip. This requires sending only 3 bytes: address, function code and new setting - taking a couple of hundred microseconds at most. The whole TWI process happens with interrupts turned on, and it doesn't seen to matter whether I use the TWI interrupt to wake up the CPU or I simply loop until complete.
I have a debug program attached to USART 0, streaming out data at 115200 baud, and also two software UARTS at 9600 baud using timers 1 and 3. These all work fine until I use the TWI interface to send the three bytes mentioned above, at which point data gets lost on USART 0 and/or either of the two software UARTs, and data flow seems to stop, sometimes for a second or more at a time, exactly as if the processor had interrupts turned off for that time. Then the program picks up as if nothing had happened, except for some occasions when the watchdog times out and there is a reset - and of course the program gives an error if any serial data has been lost during the outage.
I would assume I was doing something silly, but the TWI routines have worked fine in several other projects, transferring a lot more data than I am attempting at the moment, and as I said the same program seems to run fine with the Mega128. Unfortunately the Mega128 is not a long-term option as at some point I will need the CAN bus (I'm not using it yet).
Has anyone else seen any funnies which seem to have been introduced into the TWI in the CAN128?