Hi Guys I got as far as programmed chip so happy "But" the 328p chip i programmed with avr studio 5.1 doesnt blink just stays on solid light ???Code
#define F_cpu 20000000L
#include <avr/io.h>
#include <avr/delay.h>
int main(void)
{
DDRB = 0x01;
PORTB =0;
while(1)
PORTB = 0x01;
_delay_ms(1000);
PORTB =0;
_delay_ms(1000) }
my light stays on its supposed to blink from off of my 328p (real close though love my usbtiny , please help me) newbe
USBtiny programmer to 328p chip
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: USBtiny programmer to 328p chip
You need a set of braces after the while() loop:
C's while() loop executes the next 'expression' it sees. Individual commands are expressions, but braces create a single expression that contains several commands.
Without the braces above, your uP was seeing:
and ignoring everything after that.
Code: Select all
#define F_cpu 20000000L
#include <avr/io.h>
#include <avr/delay.h>
int main(void) {
DDRB = 0x01;
PORTB =0;
while(1) {
PORTB = 0x01;
_delay_ms(1000);
PORTB =0;
_delay_ms(1000)
}
}
Without the braces above, your uP was seeing:
Code: Select all
while(1) {
PORTB = 0x01;
}
Please be positive and constructive with your questions and comments.