Shop OBEX P1 Docs P2 Docs Learn Events
FlexC for P1 — Parallax Forums

FlexC for P1

It's been a while since I tried FlexC or programmed the P1 but I have a simple application I'd like to write for the QuickStart board and am wondering if CMM for P1 has been implemented in FlexC yet. I'd rather use FlexC but if that isn't possible I'll go back to propgcc.

Comments

  • Wuerfel_21Wuerfel_21 Posts: 4,374
    edited 2022-06-23 23:44

    There's some vestigial CMM support, but IIRC doesn't work.

    You can, however, compile C to Spin bytecode. Some limitations apply (most notably, no varargs (simple printf is fine due to the compiler turning it into individual print calls) and no alloca/VLA) and there may also be bugs.

    Also, depending on how long "It's been a while" is, you may be surprised that the LLM codegen is a good bit better now (though not, like, groundbreaking). Not an ideal testcase (because spin, already very size-optimized and a good couple of improvements preceding compiler versions that can build it), but v5.9.12 saves 824 bytes vs. v4.3.0 on compiling Spin Hexagon (29360 vs 28536 bytes). Stack usage is also lowered by some amount.

  • I didn't know that the LLVM compiler could generate P1 code. I thought it was only for P2.

  • evanhevanh Posts: 15,126

    That would've been a typo for LMM.

  • @evanh said:
    That would've been a typo for LMM.

    Ah, that makes more sense. I suppose I could do this on the P2. Really, all I want to do is write a program that will spit out a line of text every couple of seconds to use as a source of data for some CH599 code I'm working on. I need a device that can provide a USB host interface to a microcontroller that implements the CDC virtual serial protocol. I picked up one of Matthew Matt's CH559 modules from Tindie and am trying to add CDC support to its firmware.

    https://www.tindie.com/products/matzelectronics/ch559-usb-host-to-uart-bridge-module/

  • Never mind. My program is so simple that flexcc in LLM mode only results in a program that is 1380 bytes long and that, of course, easily fits on the P1.

    Thanks, Eric! Your stuff "just works"!

  • evanhevanh Posts: 15,126

    Oh, ah, it is the host. I had to read the description to understand: "CH559 USB Host to UART Bridge Module allows you to connect USB devices like a keyboard, mouse, or game controller to any microcontroller (Arduino, AVR, M0/M4, ESP8266/ESP32, Propeller, etc.) that has an available serial/UART input."

  • @evanh said:
    Oh, ah, it is the host. I had to read the description to understand: "CH559 USB Host to UART Bridge Module allows you to connect USB devices like a keyboard, mouse, or game controller to any microcontroller (Arduino, AVR, M0/M4, ESP8266/ESP32, Propeller, etc.) that has an available serial/UART input."

    And it even includes sample code for the Propeller!

  • @"David Betz" said:
    It's been a while since I tried FlexC or programmed the P1 but I have a simple application I'd like to write for the QuickStart board and am wondering if CMM for P1 has been implemented in FlexC yet. I'd rather use FlexC but if that isn't possible I'll go back to propgcc.

    Hi David! It's great to see you again. As Ada mentioned, FlexC is (mostly) supported by the P1 bytecode back end that she wrote, so many C programs can be compiled to bytecode now. We're still working on getting the last few features implemented, if you find something that doesn't work and that you need please let me know!

Sign In or Register to comment.