Blinking LED in pure C.

I setup Code::Blocks on Linux and Windows and a arm-gcc toolchain than I build "libsam_sam3x8e_gcc_rel.a"

here are my first working test.

DJ

blink.c (8.88 KB)

here are the log file.

-------------- Build: default in test01 (compiler: AT91SAM GNU GCC Compiler)---------------

arm-none-eabi-gcc.exe -Os -Wall --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fdata-sections -nostdlib -std=c99 -I..\AT91SAM3X8E -Isam -Isam\libsam -Isam\CMSIS\Device\ATMEL -Isam\CMSIS\CMSIS\Include -c blink.c -o obj\blink.o
arm-none-eabi-g++.exe -Llib -Lsam\ld -o test01.elf obj\test01.o  -s -Wl,-Map=blink.elf.map -Tflash.ld -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group lib\libsam_sam3x8e_gcc_rel.a -Wl,--end-group  -lsam_sam3x8e_gcc_rel
Output file is blink.elf with size 65.54 KB
Running target post-build steps
cmd /c "arm-none-eabi-objcopy.exe -O binary blink.elf blink.elf.bin"
cmd /c "resetComPort.exe"
reset device on port COM2:
cmd /c "bossac.exe  --port=COM2 -U false -e -w -v -b blink.elf.bin -R "
Erase flash
Write 2444 bytes to flash
[                              ] 0% (0/10 pages)
[==============================] 100% (10/10 pages)
Verify 2444 bytes of flash
[                              ] 0% (0/10 pages)
[==============================] 100% (10/10 pages)
Verify successful

Set boot flash true

CPU reset.

Process terminated with status 0 (0 minute(s), 4 second(s))
0 error(s), 0 warning(s) (0 minute(s), 4 second(s))

after the build steps you can see
I use command line tool "bossac" and a tool I wrote "resetComPort"

"resetComPort" use the free command line tool "listComPorts"

"resetComPort.bas" is a simple FreeBASIC program

chdir exepath
dim as string port
dim as integer hFile = FreeFile()

if open pipe("listComPorts" for input As #hFile) then
  print "warning: can't run listComPorts !"
  beep
else
  dim as string aLine
  while not EOF(1)
    Line Input #1, aLine
    dim as integer nChars=len(aLine)
    if nChars>4 then
      ' is it the VID of the board ?
      if instr(aLine,"VID_2341") then
        for i as integer=1 to nChars
          dim as string char=mid(aLine,i,1)
          if char=" " then exit for
          port &=char
        next
      end if
    end if
  wend
  close #hFile
end if

hFile=FreeFile()
dim as integer reseted
if len(port) then
  port &=":"
  hFile=FreeFile()
  if open com(port & "1200,n,8,1,cs0,cd0,ds0,rs" as #hFile) then
    print "error: can't open " & port
    sleep 1000: end 3
  else
    print "reset device on port " & port
    sleep 1000
    close #hFile
  end if
else
  print "warning: no device found !"
  beep : end 2
end if