a problem with attiny13

Thread Starter

eric_s88

Joined Apr 20, 2011
158
hi everyone

I want to use attiny13 avr uC in a project.

as a test I set all pins of PB to work as output (DDRB=0x3f) and set their value to "0" . I expected that I would have a voltage of 0 on the pins , but I had about 2.5~3 volts on the pins! :(
whats the matter? is the chip damaged ?

I write the code in CodeVisionAVR ..
 

DickCappels

Joined Aug 21, 2008
10,187
It sounds like you intended to do the right thing, so its more likely that there is a problem with the circuit or your code. Please post both along with your fuse settings.

What kind of programmer are you using?
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
thanks for your respond DickCappels.

I haven't written the main project code, but I write a simple led lighting code and realize when I should have the led in off mode, it has a little light .. it comes from that mentioned voltage :(

main loop of the code:

while(1)
{
PORTB=0x08;
delay_ms(200);
PORTB=0x00;
delay_ms(200);
}

fuses are the defaults : 9.6Mhz internal RC oscillator , with division factor of 8

I used stk200/300 and USB programmer
 

ErnieM

Joined Apr 24, 2011
8,377
The code you posted should toggle the pins from on to off every .2 seconds. You should be able to see them blink. A DC voltmeter may read any voltage on those pins as it is may be forced to read some average voltage.

For debugging purposes, you may just want to set the I/O pins high and see if you still get the intermediate voltage.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
The code you posted should toggle the pins from on to off every .2 seconds. You should be able to see them blink. A DC voltmeter may read any voltage on those pins as it is may be forced to read some average voltage.

For debugging purposes, you may just want to set the I/O pins high and see if you still get the intermediate voltage.
yes you are right..I had also cheked it with and I see the blink but, when the led most be completely off, it has a little light. I mean it has a little light in its off mode.
 

kubeek

Joined Sep 20, 2005
5,795
You sure your oscillator setting is correct, so that you have the correct delay?
Also you can try simply:
Rich (BB code):
int main(void){
  DDRB=0x3F;
  PORTB=0b00101010;//alternating bits
  while(1);
}
and check what you get on the outputs. Also check if the pins are not overriden by something like jtag, backwards compatibilty fuse, adc being on by default, etc.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
You sure your oscillator setting is correct, so that you have the correct delay?
Also you can try simply:
Rich (BB code):
int main(void){
  DDRB=0x3F;
  PORTB=0b00101010;//alternating bits
  while(1);
}
and check what you get on the outputs. Also check if the pins are not overriden by something like jtag, backwards compatibilty fuse, adc being on by default, etc.
hi kubeek, I tried the code you've posted, the problem is still exists..

leds wich are on pins with value of "1" has their light

and leds on pins with value of "0" aren't off and have a light weaker than on leds.. :(
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
yes I set them like this: DDRB=0x0f; ( which set PB0~PB3 as outputs )
PORTB=0b001010; ( which set PB1&PB3 to 1 , and PB0&PB2 to 0)
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
is it possible that my programmer have some problem and don't transfer hex file correctly to the flash ?? I've programmed many atmega16 and atmega32 chips with this programmer and its the first time I'm going to use a uC from attiny family
 

kubeek

Joined Sep 20, 2005
5,795
What is your power supply?
I am not sure about the programmer, but are you sure you are using the correct header file for your chip, i.e. correctly set mmcu in your makefile/ide?

Frankly I never used attiny or codevision, so maybe try asking on avrfreaks as well.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
0-30V transformer power supply, if you meant this. yes I use CodeVisionAVR V2.05.3 as my compiler.. I have programmed and designed much more complicated microbased circuits but only with atmegas. I feel something obvious is wrong or otherwise programmer is not working correctly or chip is damaged ,meanwhile I used 2 different attiny13 for making sure either problem is the chip or not
 

MrChips

Joined Oct 2, 2009
30,824
Are you testing the output with a DVM or with an oscilloscope?

I can see no reason why your output is not 0V or 5V.
There is always a possibility that the chip is damaged. Can you try another chip?
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
hi MrChips, I test them with Dc voltmeter , and also test them by led.

yes I have 2 chips and tested them,had same problem.

I have to mention that before using of usb programmer I programmed them by stk200/300 programmer 2 or 3times and after that stk200/300 programmer couldn't program chip anymore and gave error.

now I use usb programmer with 2 kind of software, one program the chip , and the other give a mismatch error and dont program
 

MrChips

Joined Oct 2, 2009
30,824
The problem with testing with a DVM or LED is how do you know that the output is not toggling at such a high frequency that you cannot observe the changes.

You either have to be certain that the delay function is working correctly at a slow rate

or just output static LOW and HIGH voltages and measure with DVM.

I don't have ATtiny13 but I do have ATtiny15 that I can see if I can replicate your situation.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
Im sure that delay function work correctly , I have no problem with that, I see the output toggling and its working. but the problem is that when I set a bit of output to be "0".. it doesn't .. and provide that annoying voltage :(
 
Top