EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

JTAG muxed ADC channels on AVR?

Started by larwe September 12, 2010
"Hans-Bernhard Br&#4294967295;ker" <HBBroeker@t-online.de> wrote in message 
news:i6jb84$tli$00$1@news.t-online.com...
> On 12.09.2010 20:51, larwe wrote: > >> Bugger. That answer is concise, accurate, and a complete pain in my >> rump. > > Hmm... reminds me of that joke about an answer that must have been given > by a mathematician because it's so wonderfully short, extremely correct, > .... and completely useless.
Hmm, I'm not short, when correct extremely so, and completely useless (according to the wife)... and of course a mathematician by training. I take offense that mathematical answers can be the butt of jokes. Many modern theorems are extremely long. The are correct or not, so 'extremely' is superfluous. Further, the answer can't be useless if it is an answer to the question unless the question itself was set up that way. :-) Peter
On Sep 12, 11:17=A0pm, kevin93 <ke...@whitedigs.com> wrote:

> You can disable the JTAG interface under program control even if the > fuses have it enabled. =A0So depending on your application it may be
I didn't know that! Thanks for the info.
On Sun, 12 Sep 2010 11:08:02 -0700 (PDT), larwe <zwsdotcom@gmail.com>
wrote:

>I'm using ATmega169P in an application and just came across a need for >an additional two ADC channels (0-3 are in use). Unfortunately on this >part, ADC4-7 are muxed with JTAG pins. I've had no luck getting the >micro to read those channels > >Is it necessary to disable the JTAG interface via fuse settings in >order to use these upper ADCs? That's a real drag for me... means I >have to dig out my AVR-ISP to program it over SPI, and I won't be able >to do any further debugging :( > >[Obviously I am not expecting to use the JTAG interface simultaneously >with having those pins work as ADCs. I just don't want to lock off the >JTAG just yet...] > >thanks.
You can disable the JTAG pins in software. Obviously you cannot then debug via JTAG from that point, but it means you can still use the JTAG pins fro programming the device. Try this snippet I got off the web. void disable_JTAG(void) { unsigned char sreg; sreg = SREG; cli(); MCUCR |= ( 1 <<JTD ); MCUCR |= ( 1 <<JTD ); SREG = sreg; } You have to access the register twice in 4 cycles. Regards Anton Erasmus
On Sep 13, 11:48=A0am, Anton Erasmus <nob...@spam.prevent.net> wrote:
> On Sun, 12 Sep 2010 11:08:02 -0700 (PDT), larwe <zwsdot...@gmail.com> > wrote: > > >I'm using ATmega169P in an application and just came across a need for > >an additional two ADC channels (0-3 are in use). Unfortunately on this > >part, ADC4-7 are muxed with JTAG pins. I've had no luck getting the > >micro to read those channels > > >Is it necessary to disable the JTAG interface via fuse settings in > >order to use these upper ADCs? That's a real drag for me... means I > >have to dig out my AVR-ISP to program it over SPI, and I won't be able > >to do any further debugging :( > > >[Obviously I am not expecting to use the JTAG interface simultaneously > >with having those pins work as ADCs. I just don't want to lock off the > >JTAG just yet...] > > >thanks. > > You can disable the JTAG pins in software. Obviously you cannot then > debug via JTAG from that point, but it means you can still use the > JTAG pins fro programming the device.
Yes, for the first time. If you have the software running with jtag disabled, you still have to erase/reprogram it with SPI.
> > Try this snippet I got off the web. > > void disable_JTAG(void) > { > =A0 =A0 =A0 =A0 unsigned char sreg; > > =A0 =A0 =A0 =A0 sreg =3D SREG; > =A0 =A0 =A0 =A0 cli(); > =A0 =A0 =A0 =A0 MCUCR |=3D ( 1 <<JTD ); > =A0 =A0 =A0 =A0 MCUCR |=3D ( 1 <<JTD ); > =A0 =A0 =A0 =A0 SREG =3D sreg; > > } > > You have to access the register twice in 4 cycles. > > Regards > =A0 =A0Anton Erasmus
On 13 Sep., 20:48, Anton Erasmus <nob...@spam.prevent.net> wrote:
> On Sun, 12 Sep 2010 11:08:02 -0700 (PDT), larwe <zwsdot...@gmail.com> > wrote: > > >I'm using ATmega169P in an application and just came across a need for > >an additional two ADC channels (0-3 are in use). Unfortunately on this > >part, ADC4-7 are muxed with JTAG pins. I've had no luck getting the > >micro to read those channels > > >Is it necessary to disable the JTAG interface via fuse settings in > >order to use these upper ADCs? That's a real drag for me... means I > >have to dig out my AVR-ISP to program it over SPI, and I won't be able > >to do any further debugging :( > > >[Obviously I am not expecting to use the JTAG interface simultaneously > >with having those pins work as ADCs. I just don't want to lock off the > >JTAG just yet...] > > >thanks. > > You can disable the JTAG pins in software. Obviously you cannot then > debug via JTAG from that point, but it means you can still use the > JTAG pins fro programming the device. > > Try this snippet I got off the web. > > void disable_JTAG(void) > { > =A0 =A0 =A0 =A0 unsigned char sreg; > > =A0 =A0 =A0 =A0 sreg =3D SREG; > =A0 =A0 =A0 =A0 cli(); > =A0 =A0 =A0 =A0 MCUCR |=3D ( 1 <<JTD ); > =A0 =A0 =A0 =A0 MCUCR |=3D ( 1 <<JTD ); > =A0 =A0 =A0 =A0 SREG =3D sreg; > > } > > You have to access the register twice in 4 cycles. >
yep the 4 cycles is important, remember doing multiple variations of code and compiler setting before I gave up and wrote it in asm to make it work -Lasse
langwadt@fonz.dk skrev:
> On 13 Sep., 20:48, Anton Erasmus <nob...@spam.prevent.net> wrote: >> On Sun, 12 Sep 2010 11:08:02 -0700 (PDT), larwe <zwsdot...@gmail.com> >> wrote: >> >>> I'm using ATmega169P in an application and just came across a need for >>> an additional two ADC channels (0-3 are in use). Unfortunately on this >>> part, ADC4-7 are muxed with JTAG pins. I've had no luck getting the >>> micro to read those channels >>> Is it necessary to disable the JTAG interface via fuse settings in >>> order to use these upper ADCs? That's a real drag for me... means I >>> have to dig out my AVR-ISP to program it over SPI, and I won't be able >>> to do any further debugging :( >>> [Obviously I am not expecting to use the JTAG interface simultaneously >>> with having those pins work as ADCs. I just don't want to lock off the >>> JTAG just yet...] >>> thanks. >> You can disable the JTAG pins in software. Obviously you cannot then >> debug via JTAG from that point, but it means you can still use the >> JTAG pins fro programming the device. >> >> Try this snippet I got off the web. >> >> void disable_JTAG(void) >> { >> unsigned char sreg; >> >> sreg = SREG; >> cli(); >> MCUCR |= ( 1 <<JTD ); >> MCUCR |= ( 1 <<JTD ); >> SREG = sreg; >> >> } >> >> You have to access the register twice in 4 cycles. >> > > yep the 4 cycles is important, remember doing multiple variations of > code and compiler > setting before I gave up and wrote it in asm to make it work > > -Lasse
Obviously, you can use the pin change interrupt on another pin to enable/disable the JTAG as needed. If the pin is also enables a buffer, you don't have to remove the JTAGICE Mk II. -- Best Regards Ulf Samuelsson These are my own personal opinions, which may or may not be shared by my employer Atmel Nordic AB

The 2024 Embedded Online Conference