Reply by Ulf Samuelsson September 13, 20102010-09-13
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
Reply by lang...@fonz.dk September 13, 20102010-09-13
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
Reply by linnix September 13, 20102010-09-13
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
Reply by Anton Erasmus September 13, 20102010-09-13
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
Reply by larwe September 13, 20102010-09-13
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.
Reply by Peter Dickerson September 13, 20102010-09-13
"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
Reply by kevin93 September 13, 20102010-09-13
On Sep 12, 11:08=A0am, 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 interface under program control even if the fuses have it enabled. So depending on your application it may be appropriate to have JTAG disabled when needed by the program and enabled when you need it for programming/debugging. kevin
Reply by Vladimir Vassilevsky September 12, 20102010-09-12

Hans-Bernhard Br=F6ker wrote:

> On 12.09.2010 20:51, larwe wrote: >=20 >> Bugger. That answer is concise, accurate, and a complete pain in my >> rump. >=20 >=20 > Hmm... reminds me of that joke about an answer that must have been give=
n=20
> by a mathematician because it's so wonderfully short, extremely correct=
,=20
> ..... and completely useless.
Reminds me of that joke about an answer that must have been given by a=20 manager: somebody else's design problem from now on must become my=20 personal problem. VLV
Reply by September 12, 20102010-09-12
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.
Reply by larwe September 12, 20102010-09-12
On Sep 12, 2:56=A0pm, hamilton <hamil...@nothere.com> wrote:

> You can switch to ISP over SPI.
That's exactly what I'm going to do. It just makes everything a bit irksome because I can't see what the actual ADC values are. Oh, and having to find my AVR-ISP :)