The board I am using is Due, mcu is AT91SAM3X8E.
I found a blog about pure c programming without using IDE, at here
The source code of led.c is:
#include <avr/io.h>
#include <util/delay.h>
#define BLINK_DELAY_MS 2000
int main (void)
{
/* set pin 5 of PORTB for output*/
DDRB |= _BV(DDB5);
while(1) {
/* set pin 5 high to turn led on */
PORTB |= _BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
/* set pin 5 low to turn led off */
PORTB &= ~_BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
}
}
And the compile command is :
avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c
avr-objcopy -O ihex -R .eeprom led led.hex
sudo avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:led.hex
Although the example is based on UNO, avr-gcc and avr-objcopy works fine, but avrdude failed with the message:
"
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
"
So my question is:
- What -mmcu option should be for DUE, whose mcu is cortex-3, AT91SAM3X8E??
- How to fix the avrdude problem in pure C environment without IDE?
( The example works with IDE file->examples->basic->blink)
THANKS A LOT!