Recent

Author Topic: Arduino DUE and Free Pascal.  (Read 8264 times)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8901
  • FPC developer.
Arduino DUE and Free Pascal.
« on: September 30, 2016, 12:21:47 pm »
Anybody have experience with FPC and an Arduino DUE (which is a Cortex M3 SAM3X8E) or similar ARMs ?

I'm planning to connect a W5500 to an Arduino DUE and port a minimal UDP-only stack over to it, but coming from dsPIC33e, I'll have to start at the bottom, the datasheet looks fairly daunting.

Peripherals that I need
 - DMA a block (read/write) to SPI
     - with CS going low before the transfer, and up again after. (e.g. in the DMA finished interrupt).
     - Some notifications that it is finished. (dma finished interrupt again)
     - 8/16/32-bit DMA, does it matter?  (e.g. dspic33e has two bit pauses between units, so 16-bit DMA saves 2 bits per 16-bits send (18 instead of 20 bits per 16-bits payload)
 - Watching the INT pin with some hardware pin thingy. (edge high-to-low or so)
 - updating simple volatile variables to communicate between interrupt and the main program. in dspic33e simple operations on volatiles (  e.g. int++ in an interrupt handler) can be considered atomic, and no increments or decrements are lost. How is this on ARM M3?
 - I need some form of time keeping (e.g. for the reset period of the W5500 on startup).

I'm an intermediate programmer in C, I haven't done anything embedded in FPC.

If anybody can give me tips/hints about this, that would be welcome. The hardware is still in the mail, I'm just starting to read up.
« Last Edit: September 30, 2016, 12:23:51 pm by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 10601
Re: Arduino DUE and Free Pascal.
« Reply #1 on: September 30, 2016, 01:07:33 pm »
Have a look at this thread which was very helpful to me.
http://forum.lazarus.freepascal.org/index.php?topic=30960.0
I have arduino's, but no due, though.
[edit]
OTOH I don't see that processor architecture listed on my arm compiler (fpc -i)
« Last Edit: September 30, 2016, 02:33:43 pm by Thaddy »

Laksen

  • Hero Member
  • *****
  • Posts: 658
    • J-Software
Re: Arduino DUE and Free Pascal.
« Reply #2 on: September 30, 2016, 02:43:06 pm »
Support for Cortex M3 is pretty good I would say. There's even support for SAM3X8E in trunk.

Build a compiler with
OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7m

Compile with
-Parm -Tembedded -Cparmv7em -WpATSAM3X8E -O3 -Oonostackframe

Bam. Lazarus even has code completion for the hidden RTL units. So you can code directly to it :)

Thaddy

  • Hero Member
  • *****
  • Posts: 10601
Re: Arduino DUE and Free Pascal.
« Reply #3 on: September 30, 2016, 02:52:53 pm »
@Laksen
I don't see that SAM3X8E listed when I type fpc -i (in trunk from today)

Laksen

  • Hero Member
  • *****
  • Posts: 658
    • J-Software
Re: Arduino DUE and Free Pascal.
« Reply #4 on: September 30, 2016, 03:10:41 pm »
It's sitting right there on line 965 of compiler/arm/cpuinfo.pas

So it should be there if you see the rest of them? Did you mean to write fpc -Parm -i maybe?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8901
  • FPC developer.
Re: Arduino DUE and Free Pascal.
« Reply #5 on: September 30, 2016, 09:45:04 pm »
Thaddy thanks. That is mostly unrelated to this, but since I also ordered a Arduino Mega, that might be relevant still. I thought the AVR port didn't support the lesser atmels as on Arduino.

Laksen: thanks. So that leaves me binutils and how to work with the bootloader (since I have no programmer). 

Binutils can be probably taken from arduino IDE, and that also contains linker files that can tell me more about bootloader. A lot to study :)



skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2532
    • havefunsoft.com
Re: Arduino DUE and Free Pascal.
« Reply #6 on: September 30, 2016, 10:43:20 pm »
how about Ultibo project?
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8901
  • FPC developer.
Re: Arduino DUE and Free Pascal.
« Reply #7 on: September 30, 2016, 10:51:48 pm »
how about Ultibo project?

I'm not entirely sure why that would be useful.  Seems to be geared towards heavier systems. I don't really need a kernel-application abstraction.

Note that the (wiznet) w5500 is a socket chip, not an ethernet chip. It is typically used to give slow systems some network with low overhead.

Maybe I can look at it to find out about e.g. DMA, but even then I think it is wiser to look at C examples for the exact same chip series or CMSIS

Laksen

  • Hero Member
  • *****
  • Posts: 658
    • J-Software
Re: Arduino DUE and Free Pascal.
« Reply #8 on: September 30, 2016, 11:29:35 pm »
DMA controllers are very vendor specific. Won't make sense to look at anything but the datasheet. Or ASF if you dare, but it's the worst C codebase in existance :(

avra

  • Hero Member
  • *****
  • Posts: 2044
    • Additional info
Re: Arduino DUE and Free Pascal.
« Reply #9 on: October 02, 2016, 07:50:31 pm »
I need some form of time keeping
You could either implement an NTP client, or use some battery backed I2C RTC chip like MCP7940. The choice depends on your needs.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018