Hi, new to the bare metal scene. i am using the atmel studio 7 with a usbasp programmer and i am having the same problem. here is my code.
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
/*Set to one the fifth bit of DDRB to one
**Set digital pin 13 to output mode */
DDRD = 0xFF;
/* Replace with your application code */
while (1)
{
PORTD = 0xFF;
_delay_ms(50);
PORTD = 0x00;
_delay_ms(50);
}
}
the output console gives this message but the port D LED does not flash.
avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
avrdude.exe: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude.exe: Device signature = 0x1e9502 (probably m32)
avrdude.exe: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
avrdude.exe: reading input file "Debug\GccApplication1.hex"
avrdude.exe: input file Debug\GccApplication1.hex auto detected as Intel Hex
avrdude.exe: writing flash (162 bytes):
Writing | ################################################## | 100% 0.27s
avrdude.exe: 162 bytes of flash written
avrdude.exe: verifying flash memory against Debug\GccApplication1.hex:
avrdude.exe: load data flash data from input file Debug\GccApplication1.hex:
avrdude.exe: input file Debug\GccApplication1.hex auto detected as Intel Hex
avrdude.exe: input file Debug\GccApplication1.hex contains 162 bytes
avrdude.exe: reading on-chip flash data:
Reading | ################################################## | 100% 0.13s
avrdude.exe: verifying ...
avrdude.exe: 162 bytes of flash verified
avrdude.exe: safemode: Fuses OK (E:FF, H:99, L:E1)
avrdude.exe done. Thank you.
Your statement "port D LED" is rather strange. The LED is not connects to the whole port, it is connects to a separate pin. In your program, you also change the state of the entire port at a time. Do you understand the difference between a port and a pin?
What pin do you use to test either code runs or not?
i used the pin PD6. I mean if the entire port is turned on shouldnt the pins be turned on too?
srry i am not an engineer .im learniung this stuff only now.
no. but i have noticed the led can take the digital output even without a current limiter in other circuits. ill try nevertheless. just tried, not working
these were erroneous circuits.
If you use led without resister you can easily fry the pin of your controller.
Add the resistor of 300-500 Ohm and change the pin, may be you damaged it already.