PORTC of ATMEGA324P acting funny

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

Trying to hook up 4 Seven Segment Displays to my ATMEGA324P.

PD0-PD3 passes power to the common anode of each digit one at a time. As each digit is powered, each segment has its current sunk into PC0-PC7 (also one at a time).

All of the displays have been tested.

I've checked continuity from the cathodes to their respective pins on PORTC.

Either PC2-PC5 are busted, or there's a mistake in my code:

#include 
#include 

int main (void){
	DDRC = 0xFF; // set as output, sink current
	DDRD = 0x0F; // first 4 pins output, source current
	PORTC = 0x00;
	PORTD = 0x00;
	
	while(1){
		for (int j = 0; j < 8; j++){
			// set the segment pin low (sink)
			PORTC = ~(1<<j);
			for (int i = 0; i < 4; i++){
				PORTD |= (1<<i);
				_delay_ms(20);
				PORTD = 0x00;
			}
		}
	}
}

This is the weirdest glitch I've ever encountered. Any input is greatly appreciated!

I know that the port groups on this micro can only source/sink 100mA simultaneously, but because I'm only lighting one segment at a time, I don't think this would be an issue.

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

or you have jtag enabled.

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

This is a double post!!

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I know!! haha but this one was posted first so i answered in this one :)

Now; someone delete it please