Mega169 port E output

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

When I set some port E pins as output on my mega169 they immediately have a high level. I expected the output level would be low, until I set them high.

When I run my software on the simulator, the output pins are low.

Is there something wrong with my mega169?

Last Edited: Tue. Oct 19, 2004 - 12:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are internal pullup resistors to vcc.... so when the output is off, the pin gets pulled up. When you turn it on, it pulls down to ground.

Imagecraft compiler user

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

It's not the pullups. They can't source this much current and they wouldn't be enabled when the pin direction is out. At least I don't think so.

I didn't explain the situation very well. I can set the output high or low but I expected these pins to start out low.

I think I have the answer though. The PORTE register is 0xff when my program gets control. On the Butterfly my program doesn't get control from reset directly. It gets control from the "bootloader" program. So I guess the "bootloader" is setting the PORTE register to all one bits.

The bootloader reads some of the switches on the joystick and some of the port E pins are used for that. So the guy that wrote the bootloader probably set all the pins high to make sure he got the right ones.

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

Yes, from the BF-Bootloader-Code:

__C_task void main(void)
{
    ...
    PORTB = 0xFF;       // Enable pullup on 
    PORTE = 0xFF;
    ...

.

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

Okay, just as I suspected. I looked briefly for the bootloader source but all I found was the app note 109 stuff that didn't read switches.

Thanks,