pin direction example in prop c
pilot0315
Posts: 953
in Propeller 1
I have been struggling with the pin direction commands in prop C.
I want to take this from SPIN:
dira[CS_PIN]~~
dira[WR_PIN]~~
dira[RS_PIN]~~
dira[REST_PIN]~~
dira[14..7]~~
dira[disp_pin]~~
to propeller C.
The information in the propgcc manual is not forthcomming
Any suggestions wold help. I have tried the suggestions in:
https://learn.parallax.com/tutorials/robot/elev-8/io-elev-8-flight-controller/pin-control-registers
copied and pasted the stuff there but got error messages.
Thanks
Looking in the
I want to take this from SPIN:
dira[CS_PIN]~~
dira[WR_PIN]~~
dira[RS_PIN]~~
dira[REST_PIN]~~
dira[14..7]~~
dira[disp_pin]~~
to propeller C.
The information in the propgcc manual is not forthcomming
Any suggestions wold help. I have tried the suggestions in:
https://learn.parallax.com/tutorials/robot/elev-8/io-elev-8-flight-controller/pin-control-registers
copied and pasted the stuff there but got error messages.
Thanks
Looking in the

Comments
They are both documented at the following link:
https://cdn.rawgit.com/parallaxinc/propsideworkspace/master/Learn/Simple%20Libraries%20Index.html
simpletools.h is as its name suggests the easy way. I have copied the IO pin functions and brief descriptions below.
The other library is propeller.h. For the pins the propeller.h library does not use functions. You enter the 32 bit pin values into:
The advantage of propeller.h is that it may be a more familiar way for people used to spin or PASM, and it executes faster than the simpletools.h functions.
Hope this helps,
Tom M.
void setup() { DIRA |= 1 << CS_PIN; DIRA |= 1 << WR_PIN; DIRA |= 1 << RS_PIN; DIRA |= 1 << REST_PIN; DIRA |= 0xFF << 7; DIRA |= 1 << DISP_PIN; }// // automatically generated by spin2cpp v3.6.4 on Sat Mar 10 22:09:26 2018 // /home/ersmith/Parallax/spin2cpp/build/spin2cpp --ccode foo.spin // #include <stdlib.h> #include <propeller.h> #include "foo.h" #ifdef __GNUC__ #define INLINE__ static inline #else #define INLINE__ static #define waitcnt(n) _waitcnt(n) #define coginit(id, code, par) _coginit((unsigned)(par)>>2, (unsigned)(code)>>2, id) #define cognew(code, par) coginit(0x8, (code), (par)) #define cogstop(i) _cogstop(i) #endif void foo_test(void) { DIRA |= (1 << FOO_CS_PIN); DIRA |= (255 << 7); }The stuff inside the "#ifdef __GNUC__" block is fluff that allows the output to be compiled by Catalina as well as PropGCC, so you can ignore that. The interesting stuff is the foo_test() function, where you can see how to set DIRA the way Spin does.
I tried the method like the one Johnny Mac indicated but I got error messages. I will post it.
Thanks to all.
I will get back
thanks
See attached it did not compile. The errors are the same that I got originally.
Thanks