PortB0 stuck at 2.5V

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

Hi Freaks,

I am using a M328P and am using PORTB pins as output pins.

My code to set PORTB as output is very simple:

	   DDRC = 0x0F;
	   DDRD = 0xC0; 
	   DDRB = 0xFF;
	   PORTC = 0x00;
	   PORTD = 0x00;
	   PORTB = 0x01;

I am making PORTB0 high.

However when I measure the voltage on the PORTB0 when I turn on the power, I get 2.5V (about half of supply voltage).

All the other PORTB channels are working fine.

What could be the problem? Did I fry the chip?

Thanks.

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

Perhaps the pin is connected to another pin.
One pin drives high, the other low, result
about 2.5V. So check the other pins

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

I had a similar issue when I tried to access a port that was setup as an input. I needed to make PINB = 0x00. PINB for input, PORTB for outputs. This is probably not your problem as mine was a noob mistake

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

CKOUT Fuse programmed?

Quote:
ICP1/CLKO/PCINT0 – Port B, Bit 0

CLKO, Divided System Clock: The divided system clock can be output on the PB0 pin.
The divided system clock will be output if the CKOUT Fuse is programmed, regardless
of the PORTB0 and DDB0 settings. It will also be output during reset.

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

That did it,sbennet. Wow, I would never have stumbled upon it. I guess reading the datasheet helps. Thanks.

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

That was my guess - 2.5V is 50/50 duty cycle :)

Cheers,

Joey