So your problem is that you are trying to write some code to run on, say, an ATtiny85 that is acting as an I2C slave - perhaps to control a servo or some NeoPixels. Without the cost of JTAG how do you debug the code?
We came up with the following solution - not 'rocket science' and 'obvious maybe' when you think about it.
Our problem was to write code for an ATTiny85 which would listen on the I2C bus and control a string of high power LEDs. The ATtiny85 only has a USI - not a proper UART- so its hard to dump any debug messages plus its easy to bloat the code and run out of space on this small chip. So how to do it?
- Use a bigger board which has various 'on board' gadgets or multiple UARTs like the Axon or, better, the Axon II.
- Split the resources of the board in half (mentally - not with a hacksaw!).
- One half (acting as the Master) is connected to your favourite computer terminal software to accept keyboard commands and send back messages to be displayed. It also uses two pins to define a software I2C bus.
- The other half (acting as the Slave) has the hardware I2C bus, the IO pins to talk to the LEDs, and either another UART for sending debug messages or the 8 Segment LED built onto the Axon II board.
- Now all we need to do is to connect the two I2C ports together as if they were seperate boards - you will need to add pullups from both the SDA and SCL lines to 5v using, say, 4k7 resistors.
- Create your project with each of these options set up. Your main loop should then have the code for both the master and the slave.
- Test and debug all one board !
- Once you've got it working. Create a new project for the ATtiny85 and only add the LED devices. Copy and paste the slave code in and remove any debugging stuff.
- Create a new project for the Axon and only add the devices used by the master. Copy and paste the master code in.
- Change the two I2C wires so that they connect the I2Cpins on the different boards. You will either need to continue using the external pullups or, alternatively, the master can now use the hardware I2C in which case Studio will tell you whether you need the external pullups or not.
And there you go.
WebbotLib Studio makes it so easy due to the fact that it generates and uses the correct code (believe me - it is different) for the ATtiny85 once moved off the Axon. No need to rewrite anything.