Recent

Author Topic: Teensy (no OS) programmed with Free Pascal Embedded ARM  (Read 41911 times)

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Teensy (no OS) programmed with Free Pascal Embedded ARM
« on: May 27, 2015, 02:28:38 pm »
The Teensy https://www.sparkfun.com/products/12646 looks like a nice development board to use with Free Pascal Embedded ARM http://wiki.freepascal.org/TARGET_Embedded.

http://forum.lazarus.freepascal.org/index.php/topic,26315.0.html and http://forum.lazarus.freepascal.org/index.php/topic,24665.0.html are related topics, but it is probably best to update the wiki page and this new topic going forward.

I hope we can bring a lot of new folks to Free Pascal!  :)
Regards,
Paul Breneman
www.ControlPascal.com

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #1 on: May 27, 2015, 02:46:43 pm »
I got all the usual "whats FPC" and "nobody uses FPC" when I asked about using FPC on the Teensy forums..

https://forum.pjrc.com/threads/28518-Teensy-with-Freepascal

Maybe you know ways to use FPC with Teensy?

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #2 on: May 27, 2015, 05:06:43 pm »
The controller on that board isn't directly supported by FPC yet, but adding support shouldn't be too hard. I can probably do that tonight (with the help of Michael Ring).

I got all the usual "whats FPC" and "nobody uses FPC" when I asked about using FPC on the Teensy forums..

https://forum.pjrc.com/threads/28518-Teensy-with-Freepascal

Maybe you know ways to use FPC with Teensy?
Lots of bad replies. Ignore everything said there :)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #3 on: May 27, 2015, 06:13:20 pm »
Lots of bad replies. Ignore everything said there :)
Not really, only 1-2 that discriminates Pascal. Some even know Mikroe Pascal ;)

It's nice to see FPC on embedded platforms. We always trail behind GCC but that's not a big deal, even incredible since no other might be close, even commercial ones.

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #4 on: May 27, 2015, 06:19:46 pm »
Gizmo: Thanks for the link you shared.  I just updated the following page with stuff I like to share with such people: http://turbocontrol.com/embeddedfreepascal.htm

Laksen: Please update us with your progress.  Thanks for your help!
Regards,
Paul Breneman
www.ControlPascal.com

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #5 on: May 28, 2015, 10:44:04 am »
Laksen\Paul

I have a new v3.1 Teensy so happy to help you test...

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #6 on: May 28, 2015, 01:55:58 pm »
Alright, it's committed to SVN trunk now.

To build the compiler:
make buildbase OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7em CROSSINSTALL=1

To install it:
make installbase OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7em CROSSINSTALL=1 PREFIX=C:/wherever you want to install

To build a program:
fpc -Parm -Tembedded -Cparmv7em -Wpmk20dx256xxx7 program.pas

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #7 on: May 28, 2015, 04:16:38 pm »
Don't forget to post an update on the pjrc forum :)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #8 on: May 28, 2015, 04:48:49 pm »
I would be happy to, but maybe Laksen should as he has done the work.
« Last Edit: May 28, 2015, 05:14:11 pm by Gizmo »

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #9 on: May 28, 2015, 05:13:29 pm »
Thanks Laksen for your help!

Projects Using Teensy
  http://pjrc.com/teensy/projects.html
There should be something there to interest everyone!

My favorite (so far) seems to be the Modbus project which links here:
http://forum.pjrc.com/threads/23543-RS485-half-duplex-using-Teensy-3-0-hardware-pins
I'd like to associate that with the Modbus example here: http://ctrlterm.com/custom.htm
Then maybe post a new page (with C and Python code) here: http://controlpascal.com/

If anyone wants to contribute a page for http://controlpascal.com/ please contact me.  The Free Pascal wiki page should also be updated.
Regards,
Paul Breneman
www.ControlPascal.com

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #10 on: May 28, 2015, 05:28:35 pm »
Michael Ring did most of this work since he wrote the converter  :P

But go ahead and try it. Do report any code related problem you run into as fast as possible

FPK

  • Full Member
  • ***
  • Posts: 118
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #11 on: May 28, 2015, 08:15:49 pm »
Don't forget to post an update on the pjrc forum :)

Definitively :)


Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #13 on: June 02, 2015, 03:07:57 pm »
Hopefully my Teensy (with pins), breadboard, and tutorial parts kit (all mentioned here http://www.pjrc.com/store/tutorial_kit.html) will arrive in several days.  I then hope to port the tutorials to Free Pascal!
Regards,
Paul Breneman
www.ControlPascal.com

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: Teensy (no OS) programmed with Free Pascal Embedded ARM
« Reply #14 on: June 03, 2015, 01:14:27 am »
I had access to a Teensy 3.1 so I just tested it today. There were some strange low-level details in the chip that needed fixing in the compiler and RTL. Those fixes are in SVN trunk now.

The following example will blink the led with approx 1 Hz (if compiled with -O3 or higher :) ):
Code: [Select]
program test;

procedure Delay;
  var
    i: longint;
  begin
    // 3 cycles per loop approx. at 16 MHz at -O3 optimization
    // (16 MHz / 3) * 0.5 = 2666666 ~= 0.5 sec
    for i := 1 to 2666666 do;
  end;

begin
  // Enable clock for PORTC
  SIM_bitbanded.SCGC5.PORTC := 1;

  // Set PTC5 to output
  PTC_bitbanded.PDDR.PDD[5] := 1;
 
  // Set PTC5 to ALT1(GPIO) mode and use high drive strength
  PORTC.PCR5 := ($1 shl 8) or (1 shl 6) or (1 shl 2);
 
  // Set PTC5 high
  PTC.PSOR := (1 shl 5);
 
  while true do
    begin
      Delay;
      PTC.PTOR := (1 shl 5);
    end;
end.

Binary here: http://j-software.dk/test.hex

 

TinyPortal © 2005-2018