Programming ATMega32

Thread Starter

skj

Joined May 20, 2010
22
Hi
I am new to micro controllers I am using ATMega 32, I want to achieve the following Conditions,how to write the programme in WinAVR Programmers Notepad Using C/C++ .

PinB0 as Input
PinB1 as output
PinB2 as Input

1) if B0 is 1 and PinB2 is 1 then PinB1 should be 0
2) If B0 is 0 and PinB2 is 1 then Pin B1 should be 0
3) if B0 is 0 and PinB2 is 0 then Pin B1 should be 0
4) if B0 is 1 and pinB2 is 0 then Pin B1 should be 1

Noe: 1.Input at Pin B0 will appear for a short time when Push Button is pressed momentarily
2. Input at Pin B2 will be continuous or short time depending upon the source for this signal.
 

donpetru

Joined Nov 14, 2008
185
It is not good that you have chosen PB0 as input button. Choose PB2 because it has external interrupt.

You should rethink the Atmega32 pin allocation. In your example, what you want to do PB2 could better implement software using one of the ADC pins of the microcontroller (eg PA0 ... PA7). Then choose the output pin.

The program can be written on Attiny45 or Attiny13, you no need ATmega32.
 

Shagas

Joined May 13, 2013
804
If you are new to AVR microcontrollers then you should learn the basics first before tryingto programm something .

Why are you using programmers notepad when you get free copy of atmel studio 6 ?
What programmer are you using?

Here are some links to start learning:

http://maxembedded.com/2011/06/09/avr-basics/
http://www.newbiehack.com/MicrocontrollerIntroductionABeginnersGuidetotheAtmelAVRAtmega32.aspx


Also , this forum is great for general electronics help etc , but if you want help specifically with AVR then I suggest :

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewforum&f=3

On AAC (this forum) you will mostly see people asking for help with PICs , not AVR.
 
Top