1
\$\begingroup\$

How can I debug I2C in Atmel Studio (latest)?

I have enabled it as shown inside the I/0 View with TWEN and TWIE bits enabled. However, after sending a START condition, I do not see the TWI-interrupt routine being called.

\$\endgroup\$
6
  • \$\begingroup\$ Have you got the TWI interrupt enabled in the appropriate register? \$\endgroup\$
    – Dzarda
    Commented Jul 28, 2014 at 10:55
  • \$\begingroup\$ @Dzarda: Yes (edited question) \$\endgroup\$
    – Babu James
    Commented Jul 28, 2014 at 11:32
  • \$\begingroup\$ To be honest, my knowledge of embedded debugging is rather limited. However I have used the XMega TWI module quite extensively in C/++. Random tips: Forcing the START condition in the STATUS register does not schedule any interrupt to be called. You normally write the ADDR register and the interrupt is called once all bits are sent. Also, you may not be able to see the ISR executing just by stepping the code. You may have to insert a breakpoint in the ISR. \$\endgroup\$
    – Dzarda
    Commented Jul 28, 2014 at 12:22
  • 1
    \$\begingroup\$ @Dzarda: Regarding the first random tip, in the datasheet it says after a START condition has been transmitted, the TWINT Flag is set by hard-ware. So it should fire the ISR. I indeed have a break point there. \$\endgroup\$
    – Babu James
    Commented Jul 28, 2014 at 13:08
  • \$\begingroup\$ Are you debugging hardware or in the simulator? - Are the TWI output pins configured correctly (output w/ pull-up? TWI cannot send anything if/while CLK is held low. \$\endgroup\$
    – JimmyB
    Commented Jul 29, 2014 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.