Attiny841 : Low voltage pullup resistor

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

Been a while since I used these little devices, I wanted to use an attiny to condition a signal in a project, however the pullup has me stumped.

 

I am only getting 2.5V when measured with a meter on an input line with pullup and nothing connected to it.

A external resistor would take care of the issue ofcause, but the PCB is made :)

 

Is this a know issue with attiny having very weak pullups, or am I doing this the wrong way ?

 

#include <avr/io.h>

#include <util/delay.h>
#include <avr/wdt.h>
#include "AVR035.h"

int main(void)
{

//    wdt_reset();
//    wdt_enable(WDTO_15MS);

    CLEARBIT(DDRA,0); //Input
    SETBIT(PORTA,0); //Pullup

/* commented out code */

}

.lss

0000004e <main>:
int main(void)
{
//    wdt_reset();
//    wdt_enable(WDTO_15MS);
    
    CLEARBIT(DDRA,0); //Input
  4e:    d0 98           cbi    0x1a, 0    ; 26
    SETBIT(PORTA,0); //Pullup
  50:    d8 9a           sbi    0x1b, 0    ; 27
            CLEARBIT(PORTA,7);

        _delay_ms(1);
    }
    */
  52:    80 e0           ldi    r24, 0x00    ; 0
  54:    90 e0           ldi    r25, 0x00    ; 0
  56:    08 95           ret

00000058 <_exit>:
  58:    f8 94           cli

0000005a <__stop_program>:
  5a:    ff cf           rjmp    .-2          ; 0x5a <__stop_program>

 

 

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

The code looks ok, what does the circuit look like, please provide a schematic of your h/w setup.

Another possibility, is a solder short or too much flux under the chip......  a photo of the board may help.

 

Jim

 

 

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

If you want something you've never had...

...you must be willing to do something you've never done!

Lets go Brandon!

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

No circuit really, only ISP connected, 10k on the reset line, and a 10k external resistor that I used to test if that would pull the pin to 5V (it did).

The adapter has been soldered a few times, so looks a bit messy, but another chip has the issue on the actual PCB too.

 

 

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

You do mention 5V.  What is the actual Vcc level?  Gnd connected?  Resistance to adjacent pins (with external wiring disconnected and power off)?

 

Is the AVR really coming out of reset?  How have you proven that?  Perhaps toggle another output pin in a loop with a delay of a second or so between, if you don't have a 'scope.

 

Now, your program has no main loop so it will go into the catch loop--with interrupts off.  But no harm here since no ISRs.

 

It sure would be helpful if you posted the source code and generated code that actually match...

 

WDTON fuse?

 

 

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

Thanks for the reply.

 

The active code does match, except for the commented out part, which for some reason ended up in the assembly file.

Heres the complete code, the AVR035.h is a few marcros from a appnote.

 

#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))
#define CLEARBIT(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT))
#define FLIPBIT(ADDRESS,BIT) (ADDRESS ^= (1<<BIT))
#define CHECKBIT(ADDRESS,BIT) (ADDRESS & (1<<BIT))
#define GETBIT(ADDRESS,BIT) (CHECKBIT(ADDRESS,BIT))

#define SETBITMASK(x,y) (x |= (y))
#define CLEARBITMASK(x,y) (x &= (~y))
#define FLIPBITMASK(x,y) (x ^= (y))
#define CHECKBITMASK(x,y) (x & (y))

#define VARFROMCOMB(x, y) x
#define BITFROMCOMB(x, y) y

#define C_SETBIT(comb) SETBIT(VARFROMCOMB(comb), BITFROMCOMB(comb))
#define C_CLEARBIT(comb) CLEARBIT(VARFROMCOMB(comb), BITFROMCOMB(comb))
#define C_FLIPBIT(comb) FLIPBIT(VARFROMCOMB(comb), BITFROMCOMB(comb))
#define C_CHECKBIT(comb) CHECKBIT(VARFROMCOMB(comb), BITFROMCOMB(comb))

 

 

/*
    B0-A0
    B1-A1
    B2-A3
    A7-A4
*/

#include <avr/io.h>
#include <util/delay.h>
#include <avr/wdt.h>
#include "AVR035.h"

int main(void)
{
//    wdt_reset();
//    wdt_enable(WDTO_15MS);
    
    CLEARBIT(DDRA,0); //Input
    SETBIT(PORTA,0); //Pullup
/*    
    CLEARBIT(DDRA,1); //Input
    SETBIT(PORTA,1); //Pullup    

    CLEARBIT(DDRA,3); //Input
    SETBIT(PORTA,3); //Pullup    
    
    CLEARBIT(DDRA,4); //Input
    SETBIT(PORTA,4); //Pullup    
    
    SETBIT(DDRB,0); //Output
    SETBIT(DDRB,1); //Output
    SETBIT(DDRB,2); //Output
    SETBIT(DDRA,7); //Output
    
    int16_t cnt1 = 0;
    int16_t cnt2 = 0;
    int16_t cnt3 = 0;
    int16_t cnt4 = 0;            
    
    while(1)
    {
    //    wdt_reset();

        if (GETBIT(PINA,0) == 0) cnt1 = 50;
        if (GETBIT(PINA,1) == 0) cnt2 = 50;
        if (GETBIT(PINA,3) == 0) cnt3 = 50;
        if (GETBIT(PINA,4) == 0) cnt4 = 50;

        if (cnt1 > 0) cnt1--;
        if (cnt2 > 0) cnt2--;
        if (cnt3 > 0) cnt3--;
        if (cnt4 > 0) cnt4--;                        
        
        if (cnt1 > 0)
            SETBIT(PORTB,0);
        else
            CLEARBIT(PORTB,0);
            
        if (cnt2 > 0)
            SETBIT(PORTB,1);
        else
            CLEARBIT(PORTB,1);
            
        if (cnt3 > 0)
            SETBIT(PORTB,2);
        else
            CLEARBIT(PORTB,2);
        
        if (cnt4 > 0)
            SETBIT(PORTA,7);
        else
            CLEARBIT(PORTA,7);

        _delay_ms(1);
    }
    */
}

 

 

VCC is 5.13V

GND connected.

 

The F_CPU was off due to div8 fuse not being set, but otherwise flashing a LED works.

    SETBIT(DDRB,0); //Output
    
    while (1)
    {
            SETBIT(PORTB,0);
            _delay_ms(500);
            CLEARBIT(PORTB,0);        
            _delay_ms(500);
    }

WDTON not set.

 

Resistance from A0-GND High than my meter can measure, A0-A1 16megaohms.

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

Poor contact(s) in the bradboard?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When checking for shorts, it only takes a minute longer to see the resistance between the target pin and >>all<< the other pins.

 

Or, take e.g. a 100k resistor and use as pulldown on the suspect pin.  If the V goes to 0 then the pin is pretty much floating and it is like the AVR is not running.  (Or, and it happens with a lashup, that pin or port is blown.)

 

If the V drops only a little bit then the internal pullup is indeed enabled, and something else is drawing down that pin.

 

Are you checking the voltages (and resistances) >>right on the AVR pins<<?

 

 

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: 1

The tiny841 is a bit different, it has a separate pullup enable register.

So instead of writing to the PORT register as usual, set the bit in the PUEx register instead.

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

mrono wrote:
it has a separate pullup enable register.

Well done!  I haven't used the model and wasn't aware of that.

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

Many thanks, so the 841 is a special beast :)

 

It was indeed the PUE register that needed setting.

I tried the 100k tip theusch posted and that pulled it down to 0.02V indicating that the pullup was not actually activated, but making it an output and driving it high/low correctly flashed an led so no short to prevent it from reaching 5V.