a problem with attiny13

Discussion in 'The Projects Forum' started by eric_s88, Nov 19, 2012.

  1. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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 ..
     
  2. DickCappels

    Moderator

    Aug 21, 2008
    2,656
    632
    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?
     
    eric_s88 likes this.
  3. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    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.
     
    eric_s88 likes this.
  5. n1ist

    Active Member

    Mar 8, 2009
    171
    16
    Don't forget to set DDRB. By default, pins are inputs.
    /mike
     
    eric_s88 likes this.
  6. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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.
     
  7. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1

    yes I have set that. DDRB=0x3F [all of 6pins are set as outputs):(
     
  8. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    You sure your oscillator setting is correct, so that you have the correct delay?
    Also you can try simply:
    Code ( (Unknown Language)):
    1. int main(void){
    2.   DDRB=0x3F;
    3.   PORTB=0b00101010;//alternating bits
    4.   while(1);
    5. }
    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.
     
    eric_s88 likes this.
  9. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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.. :(
     
  10. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Are you sure you didn't swap the ddrb and portb settings? That would enable pullups if i remember correctly.
     
    eric_s88 likes this.
  11. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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)
     
  12. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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
     
  13. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    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.
     
    eric_s88 likes this.
  14. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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
     
  15. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    I mean for the attiny, if it is running on 5V or 3.3V, so there is some comparison to the voltage you measure on the pins.
     
    eric_s88 likes this.
  16. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    its running on 5V, and provide 2.5~3 volts for 0 state
     
  17. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    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?
     
    eric_s88 likes this.
  18. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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
     
  19. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    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.
     
    eric_s88 likes this.
  20. eric_s88

    Thread Starter Member

    Apr 20, 2011
    157
    1
    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 :(
     
Loading...