a problem with attiny13

Thread Starter

eric_s88

Joined Apr 20, 2011
158
100ohm , but I think its not important.. I used leds as a simple test to see if the chip work correctly or not. main problem is that I have 3volts on pins that expected to be 0. this 3 volts will be considered as a "1" in digital circuits.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
this is the code, and the circuit is simply 4led connected to pins that 2 of them should turn on, and 2others must remain off.


Rich (BB code):
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.3 Standard
Automatic Program Generator
© Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : 
Version : 
Date    : 2012-11-19
Author  : Negaran
Company : 
Comments: 


Chip type               : ATtiny13
AVR Core Clock frequency: 1.200000 MHz
Memory model            : Tiny
External RAM size       : 0
Data Stack size         : 16
*****************************************************/

#include <tiny13.h>
#include <delay.h>
// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Crystal Oscillator division factor: 8
#pragma optsize-
CLKPR=0x80;
CLKPR=0x03;
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

// Input/Output Ports initialization
// Port B initialization
// Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out 
// State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 
PORTB=0x00;
DDRB=0x0F;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0A output: Disconnected
// OC0B output: Disconnected
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;

// External Interrupt(s) initialization
// INT0: Off
// Interrupt on any change on pins PCINT0-5: Off
GIMSK=0x00;
MCUCR=0x00;

// Timer/Counter 0 Interrupt(s) initialization
TIMSK0=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
ACSR=0x80;
ADCSRB=0x00;
DIDR0=0x00;

// ADC initialization
// ADC disabled
ADCSRA=0x00;

PORTB=0b001010;
while(1);

}
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
try adding
Rich (BB code):
MCUCR = 0x40
this should disable any accidental pull-ups...

also, your while(1) might be optimized out....
thanks for this info, I didnt know about PUD bit in MCUCR register.. whats its function exactly?

I tried this, noting was changed, so know Im almost sure that the chip is damaged or programmer doesn't work correctly
 

tshuck

Joined Oct 18, 2012
3,534
thanks for this info, I didnt know about PUD bit in MCUCR register.. whats its function exactly?

I tried this, noting was changed, so know Im almost sure that the chip is damaged or programmer doesn't work correctly
PUD disables pull-ups, regardless of port configuration....
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
yes with khazama software , there is no problem :


but with extreme software , seems have some error, results are different :




what should I do with this 2?? which one is correct? its confusing
 

DickCappels

Joined Aug 21, 2008
10,169
Just a note: If the port is switching between 0 and 5 volts, the voltage as seen by a DVM would be the average, so the 2.5 to 3 volts might indicate that its working.

If you put a 10k resistor to ground and still measure 2.5 to 3V then it is most certainly switching.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
Hi DickCappels, no its not switching between 0 and 5 volts, its fixed on 0 volt in the code, but have 2.5to3 volts. as I mentioned I tested it not only with DVM but also with LED.

I programmed the chip with a much more powerful programmer (tnm+2000) and the problem did't solved. :((((((((
 

tshuck

Joined Oct 18, 2012
3,534
What he meant was that the output could be switching faster than you can see.. also, a DVM measuring VDC will average your result... 50% duty cycle = 1/2Vmax which would explain your 2.5V output...
 

MrChips

Joined Oct 2, 2009
30,794
It has been a while since I last programmed an ATtiny15L.
Reading those links has jogged my memory.

I could not program the ATtiny15 at regular SPI speed. I had to increase the SPI clock period to 10μS. I am able to do this because I built my own programmer.

Also, since I am programming in ASM I can simply add ORG $0020 to start the main program from $0020.

There is a possibility that your ATtiny13 is not being programmed.
As DickCappels suggests, connect a 10kΩ resistor from an I/O pin to Vcc and measure the voltage. Connect the same resistor from I/O pin to GND and measure the voltage. If you read Vcc and GND respectively, then the pin is an input and hence the chip is not being programmed or it is damaged.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
thank you friends for your responds :)

I tried connecting 10k resistor to Vcc and GND .. and I read 2 volts in both. what does it mean ??
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
What he meant was that the output could be switching faster than you can see.. also, a DVM measuring VDC will average your result... 50% duty cycle = 1/2Vmax which would explain your 2.5V output...
I really dont understand this , that why the output must be in switching mode?? it should be simple 0 volts :( I'm really confused , friends.
 

tshuck

Joined Oct 18, 2012
3,534
I really dont understand this , that why the output must be in switching mode?? it should be simple 0 volts :( I'm really confused , friends.
I believe it was a reference to when you said you wanted to flash LEDs. Also, if your while(1) is, indeed, being optimized out, it is possible that your controller resets, making an output set to 1 appear as 2.5V....
 

DickCappels

Joined Aug 21, 2008
10,169
It means that the pin is switching rapidly between 5V and 0V and you see the average voltage because the DVM is not fast enough (the effect is the same as low pass filtering a PWM signal -the low pass filter's output = peak voltage X duty cycle. Similarly, the LED is flashing much faster than you can see.

To prove that, if you disconnect the LED and resistor from the output pin and connect it to the VDD pin, and it looks like it has about twice the current going through it, then you LED had been flashing at a high frequency.

The bottom line is that the circuit may be working well, but the frequency might be much higher than you intend.

By the way, when testing to see if an I/O pin is working, and I'm too lazy to turn on the scope, I just toggle the pin at a high rate and measure the voltage with my DVM. It is a reliable indication.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
Hey guys, the problem is solved, but the bad thing I have to say, I dont know how it was solved! I have no idea, I did the same thing I've done so far, but know it responds to my code as expected.
 
Top