USBtiny programmer to 328p chip

USB AVR Programmer and SPI interface. Adafruit's USBtinyISP.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Zachary3
 
Posts: 1
Joined: Sat Mar 30, 2013 3:59 pm

USBtiny programmer to 328p chip

Post by Zachary3 »

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

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: USBtiny programmer to 328p chip

Post by adafruit_support_mike »

You need a set of braces after the while() loop:

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) 
    }
}
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:

Code: Select all

    while(1) {
        PORTB = 0x01;
    }
and ignoring everything after that.

Locked
Please be positive and constructive with your questions and comments.

Return to “USBtinyISP”