Atmega32 PORTC as an output???

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

Microcontroller: ATmega32
Goal: Want to use PORTC as output to blink LEDs
Issue: All ports work as outputs except PORTC
Programmer: AVRisp MkII
Compiler: GCC/Win-AVR
IDE: AVR Studio 4, Version 4.15

I can't get PORTC to work as an output on my ATmega32. However, I am able to use all of the other ports as outputs. Why isn't PORTC working?

Do I need to change the fuse bits?

CODE (Borrowed and modified from "Newbie's Guide to the AVR ADC"):

#include 

int main (void)
{
   DDRC = 0b11111111; //Declares all pins on PORTC as outputs

   ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Set ADC prescalar to 128 - 125KHz sample rate @ 16MHz

   ADMUX |= (1 << REFS0); // Set ADC reference to AVCC
   ADMUX |= (1 << ADLAR); // Left adjust ADC result to allow easy 8 bit reading

   // No MUX values needed to be changed to use ADC0

   ADCSRA |= (1 << ADATE);  // Set ADC to Free-Running Mode
   ADCSRA |= (1 << ADEN);  // Enable ADC
   ADCSRA |= (1 << ADSC);  // Start A2D Conversions

   for(;;)  // Loop Forever
   {
      if(ADCH < 220) //Taking input from infrared sensor
      {

         PORTC = 0b00000010; // LED1 On
		
      }

      else
      {
         PORTC = 0b00000001; // LED2 On

      }
   }
} 
Last Edited: Sun. Mar 1, 2009 - 08:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Disable JTAG .... that's all. Welcome to the club :)

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

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

Read in the data sheet, in the section "Alternate Port Functions", about port C. (My bet is that some pins on port C hosts the JTAG interface which is on from the factory.)

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]