Yahoo Groups archive

AVR-Chat

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

Thread

tiny2313 pullups

tiny2313 pullups

2009-09-29 by blue_eagle74

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
			
		}
	}
}

Re: tiny2313 pullups

2009-09-29 by blue_eagle74

--- In AVR-Chat@yahoogroups.com, Jim Wagner <wagnerj@...> wrote:
>
> It does not need to be exactly at "logic 1". Generally with AVRs,   
> inputs recognize as logic one is anything that is above 0.6*Vcc (I  
> think, check the spec sheet).
> 
> Jim
> On Sep 29, 2009, at 4:20 PM, blue_eagle74 wrote:
> 
The pullups that work are close to 5V but the others are at 0V. I have tried a second chip with the same results.

Brian

Re: tiny2313 pullups

2009-09-29 by blue_eagle74

That is my question. They are set as inputs with pullups enabled (I think). here is a short video of what I have done. one of the switches has a pullup and the start button (not installed in this video) has a pullup working, that is it. 

Brian 
Show quoted textHide quoted text
> 
>     What are the pins at 0V?
> 
>     Mark Jordan
>

Re: [AVR-Chat] tiny2313 pullups

2009-09-29 by Jim Wagner

It does not need to be exactly at "logic 1". Generally with AVRs,   
inputs recognize as logic one is anything that is above 0.6*Vcc (I  
think, check the spec sheet).

Jim
On Sep 29, 2009, at 4:20 PM, blue_eagle74 wrote:

> 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]

Re: tiny2313 pullups

2009-09-30 by blue_eagle74

the inputs are labeled in my code and the pullups are also, I think.
The only alt function is the TCCR0A.

Brian

--- In AVR-Chat@yahoogroups.com, Jim Wagner <wagnerj@...> wrote:
Show quoted textHide quoted text
>
> Are the low pins set as input or output? Are the pull-ups turned on?  
> WHICH pins are they, because there might be an alternate function  
> turned on.
> 
> Jim
> On Sep 29, 2009, at 5:44 PM, blue_eagle74 wrote:
> 
> > That is my question. They are set as inputs with pullups enabled (I  
> > think). here is a short video of what I have done. one of the  
> > switches has a pullup and the start button (not installed in this  
> > video) has a pullup working, that is it.
> >
> > Brian
> > >
> > > What are the pins at 0V?
> > >
> > > Mark Jordan
> > >
> >
> >
> > 
> 
> 
> 
> [Non-text portions of this message have been removed]
>

Re: [AVR-Chat] Re: tiny2313 pullups

2009-09-30 by enkitec@gmail.com

blue_eagle74 wrote:
> --- In AVR-Chat@yahoogroups.com, Jim Wagner <wagnerj@...> wrote:
>   
>> It does not need to be exactly at "logic 1". Generally with AVRs,   
>> inputs recognize as logic one is anything that is above 0.6*Vcc (I  
>> think, check the spec sheet).
>>
>> Jim
>> On Sep 29, 2009, at 4:20 PM, blue_eagle74 wrote:
>>
>>     
> The pullups that work are close to 5V but the others are at 0V. I have tried a second chip with the same results.
>
> Brian
>   

    What are the pins at 0V?

    Mark Jordan

Re: [AVR-Chat] Re: tiny2313 pullups

2009-09-30 by Jim Wagner

Are the low pins set as input or output? Are the pull-ups turned on?  
WHICH pins are they, because there might be an alternate function  
turned on.

Jim
On Sep 29, 2009, at 5:44 PM, blue_eagle74 wrote:

> That is my question. They are set as inputs with pullups enabled (I  
> think). here is a short video of what I have done. one of the  
> switches has a pullup and the start button (not installed in this  
> video) has a pullup working, that is it.
>
> Brian
> >
> > What are the pins at 0V?
> >
> > Mark Jordan
> >
>
>
> 



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

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.
Show quoted textHide quoted text
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]

Re: [AVR-Chat] Re: tiny2313 pullups

2009-09-30 by John Samperi

At 10:44 AM 30/09/2009, you wrote:
>That is my question.

No, that's OUR question. You said

"I set DDRx to 0x00 and PORTx to 0xFF."

But nowhere in your code you seem to be doing this.

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

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

So again WHICH pins are you talking about?



Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: tiny2313 pullups

2009-09-30 by Andrew Mathison

Well done John, you seem to have identified the area where the mistakes are being made.
May I suggest that this is a common "beginner's" mistake as they have never learnt Hex and its relationship (as in this example that you have identified) in addressing port pins!!!
I thought it was just me that was "off base", thanks for clearing that up for me as well.....
This is a GREAT blog....

Greetings from

Andy Mathison

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

Re: tiny2313 pullups

2009-09-30 by blue_eagle74

I found it. I had to change PORTB = 0xF4 to 0xFC. I was just looking too hard and kept missing it.

Brian

--- In AVR-Chat@yahoogroups.com, "Dave McLaughlin" <dave_mclaughlin@...> wrote:
Show quoted textHide quoted text
>
> 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.

Re: tiny2313 pullups

2009-10-01 by blue_eagle74

Once I get everything done I will post a video of the simon says game I am making.

Brian

--- In AVR-Chat@yahoogroups.com, "blue_eagle74" <blue_eagle74@...> wrote:
Show quoted textHide quoted text
>
> 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
> 			
> 		}
> 	}
> }
>

RE: [AVR-Chat] Re: tiny2313 pullups

2009-10-02 by Cat C

I don't think I saw any thanks from you to the people that helped you. 

Or... did I miss something?

> To: AVR-Chat@yahoogroups.com
> From: blue_eagle74@yahoo.com
> Date: Thu, 1 Oct 2009 00:45:21 +0000
> Subject: [AVR-Chat] Re: tiny2313 pullups
> 
> I found it. I had to change PORTB = 0xF4 to 0xFC. I was just looking too hard and kept missing it.
> 
> Brian
> 
> --- In AVR-Chat@yahoogroups.com, "Dave McLaughlin" <dave_mclaughlin@...> wrote:
> >
> > 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;) 

 		 	   		  

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

Re: tiny2313 pullups

2009-10-02 by blue_eagle74

I am sorry. I got excited and hurried back to it. I thank everyone that helped out. It is appreciated.

Thanks,
Brian

--- In AVR-Chat@yahoogroups.com, Cat C <catalin_cluj@...> wrote:
Show quoted textHide quoted text
>
> 
> I don't think I saw any thanks from you to the people that helped you. 
> 
> Or... did I miss something?
> 
> > To: AVR-Chat@yahoogroups.com
> > From: blue_eagle74@...
> > Date: Thu, 1 Oct 2009 00:45:21 +0000
> > Subject: [AVR-Chat] Re: tiny2313 pullups
> > 
> > I found it. I had to change PORTB = 0xF4 to 0xFC. I was just looking too hard and kept missing it.
> > 
> > Brian
> > 
> > --- In AVR-Chat@yahoogroups.com, "Dave McLaughlin" <dave_mclaughlin@> wrote:
> > >
> > > 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;) 
> 
>  		 	   		  
> 
> [Non-text portions of this message have been removed]
>

ATMega16 + WH1602

2009-10-03 by Антощенков Роман Викторович

Hello!

Display WH1602 connected to PORTC ATMega16 and doesn't work.
Top line filled with black boxes.
I am using CodeVisionAVR 2.03 and  AVR ISP programmer.
Fuses: SPIEN = ON
       JTAGEN = ON
PORTC sharing with JTAG is it?
  Disable JTAG?
Any other solution?

-- 
Best regards,
Roman Antoshchenkov
mailto:djantoxa@rambler.ru

Re: [AVR-Chat] ATMega16 + WH1602

2009-10-03 by Richard Reeves

>        JTAGEN = ON
> PORTC sharing with JTAG is it?
Yes.

>   Disable JTAG?
Yes, it's the first thing I'd do.  The CV LCD routines work (well, they
did when I used CV years ago).



Richard

RE: [AVR-Chat] ATMega16 + WH1602

2009-10-03 by Dave McLaughlin

Is the second line OK?

Have you adjusted the contrast input to the device? If this voltage is
wrong, the display will show as solid boxes. Another reason could be the
RESET is not working.

 

Dave.
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of ?????????? ????? ??????????
Sent: 03 October 2009 23:13
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] ATMega16 + WH1602

 

  

Hello!

Display WH1602 connected to PORTC ATMega16 and doesn't work.
Top line filled with black boxes.
I am using CodeVisionAVR 2.03 and AVR ISP programmer.
Fuses: SPIEN = ON
JTAGEN = ON
PORTC sharing with JTAG is it?
Disable JTAG?
Any other solution?

-- 
Best regards,
Roman Antoshchenkov
mailto:djantoxa@rambler.ru <mailto:djantoxa%40rambler.ru> 



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

Re[2]: [AVR-Chat] ATMega16 + WH1602

2009-10-03 by Антощенков Роман Викторович

Hello, Dave.


>   
> Is the second line OK?

> Have you adjusted the contrast input to the device? If this voltage is
> wrong, the display will show as solid boxes. Another reason could be the
> RESET is not working.

Thanks Dave.
Problem solved.
Display connected to PORT shared with JTAG.
I set fuse JTAGEN  to OFF.
Contrast input was adjested.


-- 
Best regards,
Roman Antoshchenkov
mailto:djantoxa@rambler.ru

RE: Re[2]: [AVR-Chat] ATMega16 + WH1602

2009-10-03 by Dave McLaughlin

Cool.. Well found.

 

I always use JTAG for debugging so tend not to use those pins for the
application if I can avoid it so didn't think about this.

 

At least you can now get on with your project!!

 

 

Cheers,
Dave.
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of ?????????? ????? ??????????
Sent: 04 October 2009 00:32
To: Dave McLaughlin
Subject: Re[2]: [AVR-Chat] ATMega16 + WH1602

 

  

Hello, Dave.

> 
> Is the second line OK?

> Have you adjusted the contrast input to the device? If this voltage is
> wrong, the display will show as solid boxes. Another reason could be the
> RESET is not working.

Thanks Dave.
Problem solved.
Display connected to PORT shared with JTAG.
I set fuse JTAGEN to OFF.
Contrast input was adjested.

-- 
Best regards,
Roman Antoshchenkov
mailto:djantoxa@rambler.ru <mailto:djantoxa%40rambler.ru> 



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

Re: tiny2313 pullups (video)

2009-10-04 by blue_eagle74

Here is the video of the simple simon says game I made with all your help, thanks. Just for enjoyment. Not asking for improvements or comments. There are three speed levels and I am working on sound on/off fuction. This video only has 3 levels so I could show the win lights because I cant complete all 10 levels in the final project.

Brian

http://www.youtube.com/watch?v=UelmrBCtt6U

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.