Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] tiny2313 pullups

2009-09-30 by Dave McLaughlin

Hi Brian,

 

Looking at your code, you are using Port D as your input but I only see bit
3 being set for the weak pullup. (PORTD=0x04;) 

 

This would explain why you are only seeing 1 of them work.

 

To enable the pullups on the pins you are using you need to use PORTD=0x3C;

 

You did say that you tried with PORTD=0xFF and that didn't work. 

 

Do you have JTAG capability to be able to step through the code and read the
registers etc?

 

 

Regards
Dave.

 

From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of blue_eagle74
Sent: 30 September 2009 06:21
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] tiny2313 pullups

 

  

I am trying to use internal pullups on the tiny2313 but only 2 pins are
actually at a logic one. The are going to a pushbutton switch for each of
them. I have checked that the switches are open also. I set DDRx to 0x00 and
PORTx to 0xFF. I even tryed to set the PUD in the MCUCR to 0. Is there
anything else I have to do? I am using a STK-500 with codevision.

Brian

The code is in progress but this is what I have so far:

#include <tiny2313.h>
#include <delay.h>

int Pause; //Sets the pause time for level
bit Play = 0; //Sets the play bit for game in progress
int Seed = 0; //made for random number for display 
int Passes = 0; //limit number of passes to 10

main() 
{
PORTA = 0x7C;
PORTB = 0xF4;
PORTD = 0x04;

DDRA = 0x03; 
DDRB = 0x04;
DDRD = 0x03;


TCCR0A = 0x42;
TCCR0B = 0x44;

PORTD.0 = 1; // lights light up in series once on reset or start up
OCR0A = 25;
delay_ms(250);
PORTD.0 = 0;

PORTD.1 = 1;
OCR0A = 50;
delay_ms(250); 
PORTD.1 = 0;

PORTA.0 = 1;
OCR0A = 75;
delay_ms(250);
PORTA.0 = 0;

PORTA.1 = 1;
OCR0A = 100;
delay_ms(250);
PORTA.1 = 0; 

TCCR0A = 0x02;
PORTB.2 = 0;

while(1)
{
while (PIND.6) //Wait for the start button to be pushed
{
;
}

Play = 1; //Set the play var to true

if (PIND.3) //Check for level and set the delay time for delay between
display lights
{
Pause = 100;
}
else if (PIND.4) 
{
Pause = 200;
} 
else if (PIND.5)
{
Pause = 300;
}
else //default if there is none selected to level one
{
Pause = 300;
} 


while (Play) //start of game play
{
Passes = 1; //first pass

}
}
}



[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.