News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

C2Positron

Started by midali, Today at 07:33 PM

Previous topic - Next topic

midali

Install with `C2Positron_Setup_v1.4.exe`. The Positron compiler itself is not included; you need your own licensed copy to compile the result.



**What it does**

- Side-by-side editor: C on the left, Positron BASIC on the right, converted live as you type.
- Clicking a line in the Positron pane jumps to the C line it came from.
- Converts types (`uint8_t` → Byte, `int16_t` → SWord, `int32_t` → SDword, `float` → Float...), `#define`/`enum` → Symbol, functions → Proc/EndProc, if/while/do/for/switch, structs (flattened into separate variables/arrays), 2D arrays, pointer parameters (Ptr8/16/32 + AddressOf), memset/memcpy, `++`/`--` inside expressions, `?:`, hex/binary literals.
- Handles Positron specifics automatically:
  - name length limits (32 characters, Proc names 25, Proc + local name ≤ 32, type suffixes), with a table of every renamed identifier at the top of the .bas file;
  - reserved words (uses the compiler's official keyword list);
  - no parentheses around comparisons in If/While/Until conditions;
  - helper procedures for `atan2`, `floor`, `ceil`, `fmod`, `round`, `fmin`, `fmax`.
- STM32 HAL calls are replaced with compilable placeholders, each with a hint about what to use on the PIC (HRSOut, ADIn, timer registers, etc.).
- Estimates RAM usage and warns you before Positron runs out of memory.
- Every item that needs your attention is marked `' TODO` and listed in the Issues tab.

**What it does not do**

- It does not port hardware code for you. HAL/LL calls (UART, GPIO, timers, Flash, interrupts) become TODO items that you must rewrite for the PIC peripherals.
- No support for function pointers, recursion, unions (treated as structs), C string handling (`printf`, `strcmp`, ...) or 64-bit types.
- It does not guarantee identical behavior: the output compiles, but it must be reviewed and tested on real hardware.
- Standard 14-bit 16F devices (16F84, 16F628A, 16F877A) are not supported when the code uses pointers, because Positron has no Ptr8/Ptr32 on them.
- Large programs written for 32-bit MCUs may simply not fit the RAM of a PIC; the converter will tell you which arrays are too big.

**Recommended**

- Target: **PIC18F** (tested on 18F25K20, 18F27Q10, 18F47Q43, 18F27Q84). Enhanced 16F (16F1xxx, 16F18xxx) also work, with limited RAM.
- Tested with **Positron8 compiler 4.0.6.4**.
- Add the project's `.h` files (headers next to the .c file or in Inc/../Inc are picked up automatically) so constants and structs are converted exactly.
- Convert one module at a time, then link the modules with `Include`.
- Work through the TODO list in the Issues tab before compiling.

**Found a problem? Please report it**

This is the first public version, so bugs are expected. If the converter crashes, produces wrong code, or Positron reports an error on the generated file, please reply in this thread with:

1. C2Positron version (shown at the top of the window, e.g. v1.4) and the PIC device you selected.
2. The smallest piece of C code that reproduces the problem (or the file, if you can share it).
3. The Positron error message and the line it points to in the .bas file.
4. What you expected the result to be.

I will check every report and try to fix it in the next version.

Thanks for testing, and I hope it saves you some time!

by DigitAll

C2Positron

▲