Author Topic: ATMega324PB AREF issue  (Read 1478 times)

0 Members and 1 Guest are viewing this topic.

Offline DeniTopic starter

  • Regular Contributor
  • *
  • Posts: 70
  • Country: hr
ATMega324PB AREF issue
« on: January 09, 2018, 08:05:13 pm »
Just got a few samples of ATMega324PB. I would like to use it instead of ATMega324P(A) in our current project. ATMega324PB should be backwards compatible with older flavors of ATMega324 but I got stucked with external AREF for ADC. To cut the long story short - I can't get it to work as supposed. When I select external AREF, ADC always reads 0x3FF on any channel I select - like AREF is not routed to the pin. On ATMega324PB it is shared with (new) PortE, but according to Microchip, if ADC is enabled and AREF set to external, pin should be automatically re-routed as an AREF input. On the other hand, if any other reference source is selected, it works as expected....

Can anybody try it out and verify my findings, or point me in the right direction if I'm doing something wrong...?
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3025
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATMega324PB AREF issue
« Reply #1 on: January 09, 2018, 08:59:37 pm »
Well... silly question certainly, but sometimes people miss an obvious error so it bears asking, what voltage are you supplying to ARef and what input are you supplying to the selected mux - in other words, are you sure that 0x3ff is not actually the correct conversion for your inputs.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline DeniTopic starter

  • Regular Contributor
  • *
  • Posts: 70
  • Country: hr
Re: ATMega324PB AREF issue
« Reply #2 on: January 10, 2018, 07:02:59 am »
OK, to clarify things further - I just soldered ATMega324PB on the same board we are currently producing with ATMega324P. So, yes - all signals are correct with correct levels, as well as AREF (5V - same as analog&digital supply voltage). After soldering old ATMega324P back  (running the same firmware, same HEX file flashed) - everything works as supposed.
And one more thing - I've opened a ticket on Microchip's site, got some initial response from their support staff and then complete silence.
« Last Edit: January 10, 2018, 07:19:44 am by Deni »
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3025
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATMega324PB AREF issue
« Reply #3 on: January 10, 2018, 07:54:23 am »
Quote
running the same firmware, same HEX file flashed

If it was me I would recompile targetted specifically to the PB (you'll have to have an up to date avr-gcc to get the appropriate definitions, assuming you are using avr-gcc), I know the PB is supposed to be able to run P compiled code, but...

Then I would try another PB in case I had been unlucky and was trying a faulty one.

And after all that, I would go over to avrfreaks and ask there, a more targetted audience
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline DeniTopic starter

  • Regular Contributor
  • *
  • Posts: 70
  • Country: hr
Re: ATMega324PB AREF issue
« Reply #4 on: January 10, 2018, 11:06:48 am »
Your last advice is a good one, I'll try there...
 

Offline DeniTopic starter

  • Regular Contributor
  • *
  • Posts: 70
  • Country: hr
Re: ATMega324PB AREF issue
« Reply #5 on: January 11, 2018, 12:59:40 pm »
- UPDATE -

Mistery solved - ATMega324PB has an error in datasheet regarding ADC. There's control bit in ADCSRB bit 7, that controls function of AREF pin.
If it is set (and after reset it is by default), AREF pin is routed to GPIO port E pin4. If it is cleared, AREF pin functions as an ADC ref. pin (either
as an input for external AREF voltage or bypass cap. output).
 
The following users thanked this post: mikerj, Renaud


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf