Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
pdas204
PostPosted: Apr 08, 2012 - 08:38 AM
Newbie


Joined: Jan 04, 2012
Posts: 2
Location: India

Code:
#include<avr/io.h>

//DECLEARATION OF GLOBAL VARIABLE

//DECLEARATION OF FUNCTIONS
void update(int x);
int main(void)
{
//Declearation of IO Ports
DDRA=0xFF;
DDRB=0x00;
DDRC=0xFF;
DDRD=0xFF;
PORTA=0x00;
PORTB=0xFF;
PORTC=0x00;
PORTD=0xFF;
//INFANITE LOOP
while(1)
   {
      int x=PINB;
      if(x!=0xFF)
      update(x);
   }
return 0;
}
void update(int x)
{
if(x==0b11111110)
PORTD=0b00000101;
else if(x==0b11111101)
PORTD=0b00001010;
else if(x==0b11111011)
PORTD=0b00000110;
else if(x==0b11110111)
PORTD=0b00001001;
else
return;
}

Quote:
I have written this code as DDRB=0x00 and PORTB=0XFF; the internal pull up should be enabled of PORTB but during debuging the values are shown to be zero and reding of PINB is also zero where as by default it should be 1 . please help me[/code]
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
david.prentice
PostPosted: Apr 08, 2012 - 09:49 AM
10k+ Postman


Joined: Feb 12, 2005
Posts: 16547
Location: Wormshill, England

Simulator #1 with a mega32 does not seem to take any notice of your pull-ups on input pins.

In fact it copies PORTD values to PIND. (PORTD is an output port)

So you can run your Simulation if you set the PINB values manually. (and ignore the PIND values)

Since Atmel has different Simulators for different chips and Studio versions, please say which AVR and which Studio version you are using.

I find the Simulator very useful. However you need to know its limitations.

David.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
pdas204
PostPosted: Apr 14, 2012 - 11:39 AM
Newbie


Joined: Jan 04, 2012
Posts: 2
Location: India

david.prentice wrote:
Simulator #1 with a mega32 does not seem to take any notice of your pull-ups on input pins.

In fact it copies PORTD values to PIND. (PORTD is an output port)

So you can run your Simulation if you set the PINB values manually. (and ignore the PIND values)

Since Atmel has different Simulators for different chips and Studio versions, please say which AVR and which Studio version you are using.

I find the Simulator very useful. However you need to know its limitations.

David.
Thanks for your response. I am using win avr and avr studio4.17. what can I do for seeting up internal pull ups of portb for input operation
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
clawson
PostPosted: Apr 14, 2012 - 02:30 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62935
Location: (using avr-gcc in) Finchingfield, Essex, England

That would be a one line program
Code:
int main(void) {
  PORTB = 0xFF;
}
That enables input pull ups on B.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
ka7ehk
PostPosted: Apr 14, 2012 - 06:27 PM
10k+ Postman


Joined: Nov 22, 2002
Posts: 12193
Location: Tangent, OR, USA

There is no way, in the Atmel simulator, to
Quote:
seeting up internal pull ups of portb for input operation


The first question is: what would you expect to see? That the inputs are 1 all the time?

Jim

_________________
Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA

"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
 
 View user's profile Send private message  
Reply with quote Back to top
sasquach_dm
PostPosted: Jan 12, 2013 - 10:43 AM
Newbie


Joined: Sep 27, 2004
Posts: 3
Location: Alberta, Canada

I know this may not be the most wise way to do things but u can trick the sim into keeping a high on the pin if when u initialize the port. I would suggest u only do this for debug then remove the irreverent DDR code

Code:
DDRB=0xFF; // remove after debug
PORTB=0xff;
DDRB=0x00;
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits