AT90CAN128 & internal Vref

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi!

I have a lot of error with CAN128. Current problem:
I cant turn on internal Vref (M128 works well, but CAN128 doesn't work).
AVCC = 3.3V, AGND = GND, Vref = 100n external cap.
I read below code a lot but I cant find out why I cant turn on internal Vref. Vref external pin = 0.0V

VFX.
http://www.vfx.hu

ADC_Init:
clr R16
ldi R17,16 ;2*8 byte - 8 csatorna valtozoterulet = 0
ldi ZL,low(ADCCH0)
ldi ZH,high(ADCCH0)
ADCI1: st Z+,R16
dec R17
brne ADCI1

ldi R16,0b00011110
sts ADCSRA,R16 ;[7] - ADEN: ADC Enable
;[6] - ADSC: ADC Start Conversion
;[5] - ADFR: ADC Free Running Select
;[4] - ADIF: ADC Interrupt Flag
;[3] - ADIE: ADC Interrupt Enable
;[2:0] - ADPS2:0: ADC Prescaler Select Bits
;ADPS2 ADPS1 ADPS0 Division Factor
; 0 0 0 2
; 0 0 1 2
; 0 1 0 4
; 0 1 1 8
; 1 0 0 16
; 1 0 1 32
; 1 1 0 64
; 1 1 1 128

ldi R16,0b11000000
sts ADMUX,R16 ;[7:6] - REFS1:0: Reference Selection Bits
; REFS1 REFS0 Vref Selection
; 0 0 AREF, Internal Vref turned off
; 0 1 AVCC with external capacitor at AREF pin
; 1 0 Reserved
; 1 1 Internal 2.56V Voltage Reference with external capacitor at AREF pin
;[5] - ADLAR: ADC Left Adjust Result
;[4:0] - MUX4:0: Analog Channel and Gain Selection Bits
; MUX4..0 Single Ended Input
; 00000 ADC0
; 00001 ADC1
; 00010 ADC2
; 00011 ADC3
; 00100 ADC4
; 00101 ADC5
; 00110 ADC6
; 00111 ADC7

lds R16,ADCSRA
ori R16,128
sts ADCSRA,R16 ;[7] - ADEN: ADC Enable

ldi R16,0b0000000
sts ADCSRB,R16

ldi R16,0b0001111 ;ADC3:ADC0 digital pin disabled
sts DIDR0,R16

ret

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I could not see the problem. Check out the ATMEL application note AVR096: Migrating from ATmega128 to AT90CAN128.

http://www.atmel.com/dyn/resourc...

BTW, the m128 ADFR bit name has been replaced by ADATE on the at90can.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I saw AVR096 pdf. I didnt found any problem. I think this chip is dead, again. My first CAN128 chip was dead by factory (impossible to program it), this is the 2nd chip on this panel...

VFX.
http://www.vfx.hu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interest:

Note AVR096 ( http://www.atmel.com/dyn/resourc... )
on page 15, ADCSRB register bit 7 = ADHSM

CAN128 datasheet ( http://www.atmel.com/dyn/resourc... )
didnt show me that bit. See page on 268, ADCSRB.

VFX.
http://www.vfx.hu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ADHSM was in the original AT90CAN128 data sheet, but it was removed. This has happened in other AVR chips. I think there were problems with it or it didn't work at all or something. I also think it has been pulled out of every data sheet it ever appeared in.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, thx.

VFX.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I think this chip is dead, again. My first CAN128 chip was dead by factory (impossible to program it), this is the 2nd chip on this panel...

That is quite interesting. We have installed thousands and thousands of new AVR chips over the past five years, and cannot remember a single DOA. I talked about that with one of my board houses last week that does thousands of AVRs every month, and he could not recall the last time that he got a bad new AVR.

Atmel must select reject chips to fill your orders only.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You know Lee I've been doing products for almost 12 years now. I can't remember EVER getting ANY IC of ANY kind DOA - not just Atmel. I do remember we got a cross for and EEPROM once that had all the bits programmed to zero (instead of the standard one) but they all worked in the end.

Go electric!
Happy electric car owner / builder

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's the interesting part of programming. You can be pretty darn sure that every time you put the blame for a non-working app on the chip, in the end you have to admit it was all due to your own software or hardware mistakes. Pretty sobering...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I using JTAG for programming. The first CAN128 I cant to program (I cant read out the JTAG ID), the second one I can. The code is same. Im using AVR for many many years, but this is the first unworking IC. I dont think so this is a factory fault, this IC travelled a lot to me...

VFX.
http://www.vfx.hu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, problem solved...

Bahh, SW error (IC works well, programmer faults):
I read all 8 ADC chanel in loop, after readone I increment ADMUX by 1.
lds ZL,ADMUX
inc ZL
andi ZL,3
sts ADMUX,ZL

But I didnt setup Vref in this case!!!! Ahhh...I switched off Vref.

So corrected:
lds ZL,ADMUX
inc ZL
andi ZL,3
ori ZL,0b11000000 ;Setup Internal Vref again!!!!!!!!!!!!
sts ADMUX,ZL

VFX.
http://www.vfx.hu