A simple problem ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

A simple problem ?

Ray Pasco
The program file attached compiles on Win8.1 with avr-gcc and programs a Mega2560 clone dev board, but won't blink the on-board LED.

I know the programmer, AVRdude and the dev board work fine because an old hex file of a blink program actually does cause the LED to blink. It was developed some years ago on Win7 using the same compiler version.

I just can't seem to recreate the program. What do you think is wrong or missing ?

TIA, Ray


_______________________________________________
AVR-chat mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-chat

Blink.c (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A simple problem ?

Michai Ramakers
Hi Ray,

On 18 June 2016 at 06:45, Ray Pasco <[hidden email]> wrote:
>
> I know the programmer, AVRdude and the dev board work fine because an old
> hex file of a blink program actually does cause the LED to blink. It was
> developed some years ago on Win7 using the same compiler version.
>
> I just can't seem to recreate the program. What do you think is wrong or
> missing ?

Can you paste the actual GCC and avrdude command-lines, or attach a Makefile?

Michai

_______________________________________________
AVR-chat mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-chat
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A simple problem ?

Axel Wachtler
In reply to this post by Ray Pasco
Hi Ray,

sounds strange, here are my 2cents how to hunt down that issue:

- How do you compile the programm?
   Can you send the actual build output? (compile log)

- Are there warnings (e.g. about opimization level) that you have
   overseen/ignored? At least F_CPU should spec'd via the gcc-command
   line, otherwise there is at least an redefinition warning.

- Me comes to mind that delay_ms might accept 256ms max ... but I'm
   not 100% certain in the moment.

- Does the fuses of your MCU match the clock frequency?

- Making all ports to outputs of your PIC^H^H^HAVR looks a bit
   ruffian.  Just check to which pin the LED actually is connected and
   enable this pin, e.g. for PB5:

DDRB |= (1<<PB5); ... enable PB5 as output
PORTB |= (1<<PB5); ... set PB5 to 1
PORTB &= ~(1<<PB5); ... set PB5 to 0


Best Regards, Axel


Am 18.06.2016 um 06:45 schrieb Ray Pasco:
> I know the programmer, AVRdude and the dev board work fine because an
> old hex file of a blink program actually does cause the LED to blink. It
> was developed some years ago on Win7 using the same compiler version.

_______________________________________________
AVR-chat mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-chat
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A simple problem ?

Erik Christiansen-2
In reply to this post by Ray Pasco
On 18.06.16 00:45, Ray Pasco wrote:
> I just can't seem to recreate the program. What do you think is wrong or
> missing ?

What happens when the while loop is replaced with a write of 0x0F to one
port? Do you see 4 static highs and four lows? (Deduction is a process of
elimination, after all.)

If that also fails, and you're able to confirm that the board is OK
(i.e. it runs other software), check the few assembler instructions of
your creation with:

$ avr-objdump -D Blink.elf > Blink.dump

Looking at that, you'll see precisely which hardware addresses are
linked to the DDRx and PORTx symbols, and you can check them against the
ATmega2560 datasheet. You can then also confirm that your occasional
"0XFF" instead of "0xFF" is not doing anything unanticipated.

If the static test works, you can debug your use of the avr-libc
function by checking its documentation.

Erik

_______________________________________________
AVR-chat mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-chat
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: A simple problem ?

Rolf Pfister-2
In reply to this post by Ray Pasco
I think F_CPU should be defined before the #include statements.

Rolf


_______________________________________________
AVR-chat mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-chat
Loading...