| Author |
Message |
|
|
Posted: Apr 08, 2012 - 08:38 AM |
|

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]
|
|
|
| |
|
|
|
|
|
Posted: Apr 08, 2012 - 09:49 AM |
|

Joined: Feb 12, 2005
Posts: 16286
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. |
|
|
| |
|
|
|
|
|
Posted: Apr 14, 2012 - 11:39 AM |
|

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 |
|
|
| |
|
|
|
|
|
Posted: Apr 14, 2012 - 02:30 PM |
|


Joined: Jul 18, 2005
Posts: 62247
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. |
_________________
|
| |
|
|
|
|
|
Posted: Apr 14, 2012 - 06:27 PM |
|


Joined: Nov 22, 2002
Posts: 12041
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
|
| |
|
|
|
|
|
Posted: Jan 12, 2013 - 10:43 AM |
|


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