Disable JTAG in bootloader

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For an Arduino bootloader, I'd like to disable the JTAG just before jumping to the user application rather than disabling the JTAG with the fuses. This way I can always use the JTAG for debugging (but I'll have to replace the bootloader when I'm done). The JTD bit is in the MCUCR register, I think this is the correct assembly code to do the job...

 __asm__ __volatile__ (
    "in  r30,0x35\n"
    "ori R30,0x80\n"
    "out 0x35,r30\n"
    "out 0x35,r30\n"
);

For some reason it won't assemble with "MCUCR" and I have to put the actual address of 0x35 in the code.

EDIT
Just had to add

    :
    :"I"(_SFR_IO_ADDR(MCUCR))

at the end to specify the IO address as an argument number. So I guess it's correct.