[Solved] Cogc acting funny, can't read PAR variable
DavidZemon
Posts: 2,973
Main file:
Cogc file:
Pin 23 is always blinking correctly. The terminal always outputs "New cog = 1", which would be expected. However, if I try to read the PAR register, pin 16 does not blink. If I hardcode it, it does blink. Here's the build commands:
#include <PropWare/PropWare.h> #include <PropWare/pin.h> #include <PropWare/printer/printer.h> int main() { extern const unsigned int *cogc_test_code2; int newCog = cognew(cogc_test_code2, PropWare::Pin::P16); pwOut << "New cog = " << newCog << '\n'; while (1) PropWare::Pin::flash_pin(PropWare::Pin::P23); }
Cogc file:
#include <propeller.h> _NAKED int main () { int ledMask = 0x10000; // Works //int ledMask = PAR; // Does not work :'( DIRA |= ledMask; const unsigned int delay = CLKFREQ >> 2; unsigned int timer = delay + CNT; while (1) { OUTA ^= ledMask; timer = waitcnt2(timer, delay); } } extern unsigned int _load_start_cogc_test_cog[]; const unsigned int *cogc_test_code2 = _load_start_cogc_test_cog;
Pin 23 is always blinking correctly. The terminal always outputs "New cog = 1", which would be expected. However, if I try to read the PAR register, pin 16 does not blink. If I hardcode it, it does blink. Here's the build commands:
/opt/parallax/bin/propeller-elf-gcc -fno-threadsafe-statics -fno-rtti -save-temps -Os -m32bit-doubles -Wall -ffunction-sections -fdata-sections -std=gnu++0x -mlmm -I/home/david/reusable/Documents/Programming/PropellerProjects/PropWare/CMakeModules/.. -I/home/david/reusable/Documents/Programming/PropellerProjects/PropWare/CMakeModules/../simple -o CMakeFiles/CogcppTest_Demo.dir/CogcppTest_Demo.cpp.obj -c /home/david/reusable/Documents/Programming/PropellerProjects/PropWare/Examples/PropWare_CogcppTest/CogcppTest_Demo.cpp /opt/parallax/bin/propeller-elf-gcc -fno-threadsafe-statics -fno-rtti -mcog -xc++ -r -save-temps -Os -m32bit-doubles -Wall -ffunction-sections -fdata-sections -std=gnu++0x -I/home/david/reusable/Documents/Programming/PropellerProjects/PropWare/CMakeModules/.. -I/home/david/reusable/Documents/Programming/PropellerProjects/PropWare/CMakeModules/../simple -o CMakeFiles/CogcppTest_Demo.dir/cogc_test.cogcpp.cog /home/david/reusable/Documents/Programming/PropellerProjects/PropWare/Examples/PropWare_CogcppTest/cogc_test.cogcpp /opt/parallax/bin/propeller-elf-objcopy --localize-text --rename-section .text=cogc_test.cog cogc_test.cog /usr/pwcmake/bin/cmake -E cmake_link_script CMakeFiles/CogcppTest_Demo.dir/link.txt --verbose=1 /opt/parallax/bin/propeller-elf-gcc -save-temps -Os -m32bit-doubles -Wall -ffunction-sections -fdata-sections -std=c99 -mlmm -Wl,--gc-sections -oCogcppTest_Demo CMakeFiles/CogcppTest_Demo.dir/CogcppTest_Demo.cpp.obj CMakeFiles/CogcppTest_Demo.dir/cogc_test.cogcpp.cog ../../PropWare/lmm/libPropWare_lmm.a ../../libpropeller/source/lmm/libLibpropeller_lmm.a ../../simple/lmm/libSimple_lmm.a /opt/parallax/bin/propeller-load /home/david/reusable/Documents/Programming/PropellerProjects/PropWare/bin/Examples/PropWare_CogcppTest/CogcppTest_Demo -r -t
Comments
And when I hardcode the pin mask:
Try to blink pins 15 to 2, it should work as they are in range, but better pass the address of a variable instead, or the pin number shifted by 2.
and
Thanks!