You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is necessary to write the JTD bit twice in order to disable the JTAG port. From the Datasheet:
23.5.1 MCU Control Register – MCUCR
• Bits 7 – JTD: JTAG Interface Disable
When this bit is zero, the JTAG interface is enabled if the JTAGEN Fuse is programmed. If this
bit is one, the JTAG interface is disabled. In order to avoid unintentional disabling or enabling of
the JTAG interface, a timed sequence must be followed when changing this bit: The application
software must write this bit to the desired value twice within four cycles to change its value. Note
that this bit must not be altered when using the On-chip Debug system.
Whether this is the correct method is up for debate. A compiler may possibly interpret this differently and optimize out the second write or something (I am no compiler expert, this may or may not be an issue). In all test environments it has compiled correctly and worked. It may be "safer" to rewrite this in assembler to ensure the 4 cycle requirement is always met.
Will leave the issue open for now with the intention to investigate further.
Comments are welcome if anyone can advise on compiler interpretation.
is it correct (or "wanted") to execute two times the same statement in
CAN485/Examples/JTAG_Software_Disable/JTAG_Software_Disable.ino
?CAN485/Examples/JTAG_Software_Disable/JTAG_Software_Disable.ino
Line 3 in 5c797f7
The text was updated successfully, but these errors were encountered: