The Tiny45 keeps nagging me. First the silicon flaw in Timer1, and now this:
When I power the tiny45 with 3.1V, I get wrong ADC results. When I raise the supply to above 4.2V it works.
I stripped the application to just a bare minimum to show the problem.
' ADC check1 rev 1.1 HW ' Aug 16, 2012 Nard Awater ' ATtiny45 in MyLedLamps_drop_in rev1.1 HW project ' 8 MHz internal RC oscillator ' Silicon error in this Tiny45: Timer1. See errata. Kudos to snigelen for his help ' Now facing another issue with the tiny45: ADC shows strange behaviour. ' When powered with 3.1V, ADC-results are incorrect. I use the internal 1.1V reference. So that should work. ' However, I need to power it with 4.2V or more to get the correct results. ' PinB.3 = ADC3 = Oscillator Driver Current: Drv_current over 0R5 <<<<< for TEST replaced with a potmeter >>>>> ' PinB.2 = ADC1 = Vsupply ' PortB.4 = OC1B = Oscillator Drive: PWM_Drv Const Soft_uart_out = 1 Const Soft_uart_in = 0 Const F_proc = 8000000 $regfile = "Attiny45.dat" $crystal = F_proc 'Fuses '$prog &HFF , &HE2 , &HD5 , &HFF ' generated. Take care that the chip supports all fuse bytes. 'setup IO Ddrb = &B00000010 'just ddrb.1 for soft uart out Dim Long_t As Long Dim Drv_current As Word 'in mV across the shunt of 0R5 Dim Temperature As Integer 'in degrees C Config Adc = Single , Prescaler = Auto , Reference = Internal_1.1 Const Bg_ref = 1173 'calculated using actual voltmeter on Vcc 'Temperature sensor in Tiny45; defaults, not calibrated yet Const Temp_coeff = 1 Const Temp_offset = -275 'For terminal on USB connection: #if Soft_uart_out = 1 'Terminal on USB Open "comb.1:19200,8,n,1" For Output As #4 'soft UART for output on PortB.1 #endif #if Soft_uart_in = 1 'Terminal on USB Open "comb.0:19200,8,n,1" For Input As #3 'soft UART for input on PortB.0 #endif Waitms 500 'wait a while when powering up to get everything settled Do Drv_current = Getadc(3) 'to mV's; Use Long For That Long_t = Drv_current Long_t = Long_t * Bg_ref Long_t = Long_t / 1024 Drv_current = Long_t ' Drv_current = 2 * Drv_current 'in mA with shunt of 0R5 ' Print #4 , "Drv_current in mA = " ; Print #4 , "potmeter wiper = " ; Print #4 , Drv_current Temperature = Getadc(15) Temperature = Temp_coeff * Temperature Temperature = Temperature + Temp_offset Print #4 , "Temperature in degr C (not cal'd ) = " ; Print #4 , Temperature Waitms 500 Print #4 , "ADMUX = " ; Print #4 , Admux Loop 'Very formal, but I want a Happy and Clean End :-) #if Soft_uart_out = 1 Close #4 #endif #if Soft_uart_in = 1 Close #3 #endif End
@ Vcc=3.1V this is the terminal output:
ADMUX = 143
potmeter wiper = 178
Temperature in degr C (not cal'd ) = -160
The voltmeter tells 452 mV
@ Vcc=5V this is the terminal output:
ADMUX = 143
potmeter wiper = 804
Temperature in degr C (not cal'd ) = 33
The voltmeter tells 730 mV
I print ADMUX as well to make sure that Bascom does its job right. And it does.
(143 dec = &B 1000 1111 : reference 1.1V internal, Mux 15 = temp sensor)
If I'd be using the 2.56V reference, I would be quite close (with Vcc = 3.1V) to the lower limit of Vcc.
I am pretty sure this is NOT a silicon error, but I cannot find a reason for this behaviour.