NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Cannot run program

November 05, 2010
by Ralphxyz
Ralphxyz's Avatar

I have asked/discussed before the situation where the program will not run, the two black bars appear when trying to run a program. I have never found a definitive fix for this situation. Sometimes unplugging and replugging the USB cable will get things going other times a reboot was what was needed and sometimes (as now) nothing works.

Here is the kicker I can install other programs and they work fine.

The current program I am having problems with is the Led_Blink program from the Nerdkit User Guide:

#define F_CPU 14745600

#include <avr/io.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"
#include "../libnerdkits/io_328p.h"

// PIN DEFINITIONS:
//
// PC4 -- LED anode

int main() {
  // LED as output
  DDRC |= (1<<PC4);

  // loop keeps looking forever
  while(1) {
    // turn on LED
    PORTC |= (1<<PC4);

    //delay for 500 milliseconds to let the light stay on
    delay_ms(500);

    // turn off LED
    PORTC &= ~(1<<PC4);

    //delay for 500 milliseconds to let the light stay off
    delay_ms(500);

  }

  return 0;
}

Here is the Makefile:

# LED_BLINK
GCCFLAGS=-g -Os -Wall -mmcu=atmega328p 
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-vvv -c avr109 -p m328p -F -b 115200 -P /dev/cu.PL2303-0000101D
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    led_blink-upload

led_blink.hex:  led_blink.c
    make -C ../libnerdkits
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o led_blink.o led_blink.c ${LINKOBJECTS}
    avr-objcopy -j .text -O ihex led_blink.o led_blink.hex

led_blink.ass:  led_blink.hex
    avr-objdump -S -d led_blink.o > led_blink.ass

led_blink-upload:   led_blink.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:led_blink.hex:a

The only changes are in the Makefile I have full verbose turned on and the -F flag set.

I have a programmer so I can look at the fuses and try to install the .hex without the boot loader and I have other mcu's I can try.

Does anyone see anything that might lead to this behavior?

Thanks,

Ralph

November 06, 2010
by Ralphxyz
Ralphxyz's Avatar

Is it possible something is happening with the bootloader?

It seems strange that one program will load and run but another not.

Ralph

November 07, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

It is possible something is happening in the bootloader. Have you tried loading the program directly into your chip with you ISP without the bootloader to see if the program still doesn't run. Is there something in your circuit that might be pulling the programming pin low so that the bootloader stays in programming mode?

The other possibility is that your compiler is being overzealous for some reason with its optimizations. Have you tried changing the -O flag from -Os to -O0 (thats the letter "O" then a zero).

Humberto

November 07, 2010
by Ralphxyz
Ralphxyz's Avatar

Hi Humberto, no I have not done any thing just switched programs:

If I load the temp sensor program it runs correctly, then if I load the led_blink program it doesn't run.

So the circuit is identical.

I am having problems with my ISP programmers so I have not been able to test with a direct ISP load or to look at the fuses.

Just for the record I am using a Mac mini as my PC and using a ATmega328p as my mcu, if I can remember how to load a program using windows I will also try that.

I would really like to get some specific answers so I am trying to think up a test plan that I can document.

Other people, as have I, have had the black bar problem and I have been able to eventually get it to work.

Ralph

Post a Reply

Please log in to post a reply.

Did you know that you can aim and fire a servo-controlled water gun from your computer? Learn more...