M16 - PortC Non functional

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

I have the weirdest fault i have ever seen.
I have a new PCB that has some BCD switches connected to PORTC. I have 8 LEDs on PORTA and I am writing some simple code to check the hardware.

#include 
#include 
int main (void)
{
	// port 'A'
	DDRA = 0xff;	
	PORTA = 0x00;	 

	// port 'B'
	DDRB = 0xff;	
	PORTB = 0x00;	

	// port 'C'
	DDRC = 0x00;	
	PORTC = 0xff;	

	// port 'D'
	DDRD = 0x00;	
	PORTD = 0xff;	

	while(1) PORTA = PINC;
}

In this case PA2, PA3 PA4 & PA5 are always OFF ( LO)
IE PA0, PA1 PA6 and PA7 work as expected.

I have done the following:
Replaced chip with new one
turned on all PORTA , ignoring PINC
Buzzed out PWB to see if there were any stupid track faults
Tried another Board without switches fitted and tried manipulating the M16 legs
used PortB as Output
Pulled most my remaining hair

If I change code to read Port B and manipulate the pins, PortA follows PotrB.

Any suggestions what I have missed?
TIA
Matt

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

The JTAG interface is on port C, and is enabled by default. Unprogram the JTAG fuse. Read more in the data sheet, sections "Alternate Portr Functions" and "Memory Programming".

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:
The JTAG interface is on port C, and is enabled by default.

Johan,
I read the data sheet. However obviously not understanding how the JTAG port would affect me. This is the first chip I have used with a JTAG. Thanks for your help.

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

PortC pins pc2-pc5 are used by the JTAG by default therefore not user available UNLESS JTAG is off as Johan mentioned.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

You have to disable JTAGEN Fuse.

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

Quote:
You have to disable JTAGEN Fuse.

Well actually you don't HAVE to. The JTAG can be disabled from within the code using the double write of the JTD bit thing.

(but make sure it's optimised code to meet the 4 cycle requirement)

Cliff