Question

open atmell studio and write an assembly program that toggels a 8 leds for differnt collor...

open atmell studio and write an assembly program that toggels a 8 leds for differnt collor connected to portB with a custom delay time i want the code of this program

Homework Answers

Answer #1

NOTE:- This is not as same as above but it is the c programme that i have written 2 months before you can read this and i hope you will get some help

LEDs are connected to PORTC and current limiting resistors are used to limit current through them. 16 MHz crystal is used to provide clock for the Atmega32 microcontroller and 22pF capacitors are used to stabilize the operation of crystal. The 10µF capacitor and 10KΩ resistor is used to provide Power On Reset (POR) to the device. When the power is switched ON, voltage across capacitor will be zero so the device resets (since reset is active low), then the capacitor charges to VCC and the reset will be disabled. 30th pin (AVCC) of Atmega32 should be connected to VCC if you are using PORTA, since it is the supply voltage pin for PORT A.

Atmel Studio C Program

#ifndef F_CPU
#define F_CPU 16000000UL // 16 MHz clock speed
#endif

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
  DDRC = 0xFF; //Nakes PORTC as Output
  while(1) //infinite loop
  {
    PORTC = 0xFF; //Turns ON All LEDs
    _delay_ms(1000); //1 second delay
    PORTC= 0x00; //Turns OFF All LEDs
    _delay_ms(1000); //1 second delay
  }
}
  • DDRC = 0xFF makes all pins on PORTC as output pins
  • PORTC = 0xFF makes all pins on PORTC Logic High (5V)
  • PORTC = 0x00 makes all pins on PORTC Logic Low (0V)
  • _delay_ms(1000) provides 1000 milliseconds delay.
  • while(1) makes an infinite loop

You have seen that PORT registers are used to write data to ports. Similarly to read data from ports PIN registers are used. It stand for Port Input Register. eg : PIND, PINB

You may like to set or reset individual pins of PORT or DDR registers or to know the status of a specific bit of PIN register. There registers are not bit addressable, so we can’t do it directly but we can do it through program. To make 3ed bit (PC2) of DDRC register low we can use DDRC &= ~(1<<PC2). (1<<PC2) generates the binary number 00000100, which is complemented 11111011 and ANDed with DDRC register, which makes the 3ed bit 0. Similarly DDRC |= (1<<PC2) can be used set the 3ed bit (PC2) of DDRC register and to read  3ed bit (PC2) we can use PINC & (1<<PC2). Similarly we can set or reset each bit of DDR or PORT registers and able to know the logic state of a particular bit of PIN register.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write an assembly program that toggles a LED connected to pin4 of PORTB with a custom...
Write an assembly program that toggles a LED connected to pin4 of PORTB with a custom delay time.
Write a program to count number between 0 and 255 in binary using 8 LEDs connected...
Write a program to count number between 0 and 255 in binary using 8 LEDs connected to the Arduino. This code should start at 0 and loop back to 0 once it counts to 255. Delay 0.25s between counts.
1. Open “Atmel Studio” and write an assembly program to count up from 0 to 9...
1. Open “Atmel Studio” and write an assembly program to count up from 0 to 9 and show the result on a CC seven segment.
Write a microcontroller assembly program that makes the PORTB output and that blinks with a certain...
Write a microcontroller assembly program that makes the PORTB output and that blinks with a certain delay. The delay is between 250ms and 1000ms. You should use infinite loop.
Write the Assembly Code for PIC16F84A microcontroller to read a switch connected to Bit 2 of...
Write the Assembly Code for PIC16F84A microcontroller to read a switch connected to Bit 2 of PORTB. You will need to first set the pin to an input, then test whether the pin is 0 ( switch closed, if so go to existing program at label SWITCH If not the program is to continue: Add comments to each line to explain what the code does.
Discuss the relationship between the C code and the Assembly code generated by the compiler??? Especially...
Discuss the relationship between the C code and the Assembly code generated by the compiler??? Especially focus on the difference between declaration of different types of variables in assembly for example difference between the declaration of an integer variable and a character variable. URGENT PLEASE BELOW IS THE C CODE: //Toggling PORTB in C Language for Dragon12 Plus Trainer Board //with HCS12 Serial Monitor Program installed. This code is for CodeWarrior IDE //On Dragon12+ Trainer board 8 LEDs are connected...
Assembly using "Atmel" : 1- Write a program that counts from 0 to 255 and show...
Assembly using "Atmel" : 1- Write a program that counts from 0 to 255 and show the result on PORTD (shown on 8 LEDs). 2- Write a program that adds two numbers and show their sum on PORTD.
Write an assembly language program that will implement the following:       If ( (AX >=BX) AND (CX...
Write an assembly language program that will implement the following:       If ( (AX >=BX) AND (CX < DX) ) goto LoopA Else go to LoopB (Here I want you to write the whole assembly program that could run in CMD. THANK YOU
Write assembly code to create a 1 sec delay time by using Timer2?
Write assembly code to create a 1 sec delay time by using Timer2?
C program- using visual studio code. Write a program that asks for an integer and then...
C program- using visual studio code. Write a program that asks for an integer and then prints all the alternative integers from (and including) that value up to (and including) a value larger by 20. (That is, if the input is 5, the output runs from 5 to 25.) Be sure to separate each output value by a space or tab
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT