EmbeddedNim / picostdlib

Nim wrapper for the raspberry pi stdlib
MIT License
70 stars 11 forks source link

pwm failed #47

Closed Martinix75 closed 2 years ago

Martinix75 commented 2 years ago

Hi Jason, today I wanted to make a small PWM driver for an engine, but doing an initial test on the PWM (example of the library that worked ) today I got: ... [ 15%] Building C object CMakeFiles/motorPwm.dir/nimcache/motorPwm.c.obj In file included from /home/andrea/ProgPicoNim/motorPwm/csource/build/nimcache/motorPwm.c:5: /home/andrea/ProgPicoNim/motorPwm/csource/nimbase.h:276:35: error: static assertion failed: "backend & Nim disagree on size for: PwmChannel{enum} [type declared in /home/andrea/.nimble/pkgs/picostdlib-0.2.11/picostdlib/pwm.nim(23, 3)]" 276 | #define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg) | ^~~~~~ /home/andrea/ProgPicoNim/motorPwm/csource/build/nimcache/motorPwm.c:25:1: note: in expansion of macro 'NIM_STATIC_ASSERT' 25 | NIM_STATIC_ASSERT(sizeof(enum pwm_chan) == 4, "backend & Nim disagree on size for: PwmChannel{enum} [type declared in /home/andrea/.nimble/pkgs/picostdlib-0.2.11/picostdlib/pwm.nim(23, 3)]"); | ^~~~~ make[2]: *** [CMakeFiles/motorPwm.dir/build.make:76: CMakeFiles/motorPwm.dir/nimcache/motorPwm.c.obj] Error 1

the program is (easy): import picostdlib/[stdio, gpio, pwm]

let pin0 = 0.Gpio pin1 = 1.Gpio pin0.setFunction(PWM) pin1.setFunction(PWM)

let sliceNum = pin0.toSliceNum()

sliceNum.setWrap(3) sliceNum.setChanLevel(A, 1u16) sliceNum.setChanLevel(B, 3u16) sliceNum.setEnabled(true)

cmakelists.txt mofied --> target_link_libraries(motorPwm pico_stdlib hardware_adc hardware_pwm hardware_gpio) I don't understand where it may be the problem, can you make a test (maybe I am only tired toned this evening)? thank you

Martinix75 commented 2 years ago

ok i have re-tray at my home and work!!! Now I don't have the oscilloscope to see but tomorrow I try again in the laboratory, and if they work I close the post. but is isntall picostdlib 0.2.7.. now make update...

Martinix75 commented 2 years ago

I confirm !! With the picostdlib version 0.2.11 the PWM program is not compiled!

error: /PicoNim/pwwmm> piconim build pwwmm.nim pico-nim : create raspberry pi pico projects using Nim Nim command line: nim c -c --nimcache:csource/build/nimcache --cpu:arm --os:any -d:useMalloc ./src/pwwmm.nim Hint: used config file '/home/andrea/bin/nim/config/nim.cfg' [Conf] Hint: used config file '/home/andrea/bin/nim/config/config.nims' [Conf] Hint: used config file '/home/andrea/PicoNim/pwwmm/config.nims' [Conf] ...................................................... /home/andrea/PicoNim/pwwmm/src/pwwmm.nim(1, 18) Warning: imported and not used: 'time' [UnusedImport] Hint: gc: arc; opt: speed; options: -d:release 33597 lines; 0.158s; 31.668MiB peakmem; proj: /home/andrea/PicoNim/pwwmm/src/pwwmm.nim; out: /home/andrea/PicoNim/pwwmm/csource/build/nimcache/pwwmm.json [SuccessX] make: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' PICO_SDK_PATH is /home/andrea/PicoNim/pico-sdk PICO platform is rp2040. PICO target board is pico. Using board configuration from /home/andrea/PicoNim/pico-sdk/src/boards/include/boards/pico.h TinyUSB available at /home/andrea/PicoNim/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB. -- Configuring done -- Generating done -- Build files have been written to: /home/andrea/PicoNim/pwwmm/csource/build make[1]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' make[2]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' Scanning dependencies of target bs2_default make[2]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' [ 2%] Built target bs2_default make[2]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' make[2]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' [ 4%] Built target bs2_default_padded_checksummed_asm make[2]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' make[2]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' make[2]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' [ 5%] Performing build step for 'ELF2UF2Build' make[3]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build/elf2uf2' make[4]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build/elf2uf2' make[5]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build/elf2uf2' make[5]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build/elf2uf2' [100%] Built target elf2uf2 make[4]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build/elf2uf2' make[3]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build/elf2uf2' [ 6%] No install step for 'ELF2UF2Build' [ 8%] Completed 'ELF2UF2Build' make[2]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' [ 13%] Built target ELF2UF2Build make[2]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' Scanning dependencies of target pwwmm Consolidate compiler generated dependencies of target pwwmm make[2]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' make[2]: Entering directory '/home/andrea/PicoNim/pwwmm/csource/build' [ 15%] Building C object CMakeFiles/pwwmm.dir/nimcache/pwwmm.c.obj In file included from /home/andrea/PicoNim/pwwmm/csource/build/nimcache/pwwmm.c:5: /home/andrea/PicoNim/pwwmm/csource/nimbase.h:276:35: error: static assertion failed: "backend & Nim disagree on size for: PwmChannel{enum} [type declared in /home/andrea/.nimble/pkgs/picostdlib-0.2.11/picostdlib/pwm.nim(23, 3)]" 276 | #define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg) | ^~~~~~ /home/andrea/PicoNim/pwwmm/csource/build/nimcache/pwwmm.c:25:1: note: in expansion of macro 'NIM_STATIC_ASSERT' 25 | NIM_STATIC_ASSERT(sizeof(enum pwm_chan) == 4, "backend & Nim disagree on size for: PwmChannel{enum} [type declared in /home/andrea/.nimble/pkgs/picostdlib-0.2.11/picostdlib/pwm.nim(23, 3)]"); | ^~~~~ make[2]: [CMakeFiles/pwwmm.dir/build.make:76: CMakeFiles/pwwmm.dir/nimcache/pwwmm.c.obj] Error 1 make[2]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' make[1]: [CMakeFiles/Makefile2:1329: CMakeFiles/pwwmm.dir/all] Error 2 make[1]: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' make: *** [Makefile:91: all] Error 2 make: Leaving directory '/home/andrea/PicoNim/pwwmm/csource/build' andrea@localhost:~/PicoNim/pwwmm>