o.p 0 Posted February 3, 2010 Report Share Posted February 3, 2010 I've been trying to assing a variable to a pin on the GPIO port of a 12f683. I cant seem to get the syntax right, do I need to use pragma and define the variable name at the right address of that port in memory? My code is #pragma bit load @ 5.0 ; // variable (load) is being assigned to the pin 0 Any help? Thanks. Quote Link to post Share on other sites
davidb 0 Posted February 3, 2010 Report Share Posted February 3, 2010 My code is#pragma bit load @ 5.0 ; // variable (load) is being assigned to the pin 0 Just drop the #pragma i.e. bit load @ 5.0 ; // variable (load) is being assigned to the pin 0 Check the reference manual for more info. Regards davidb Quote Link to post Share on other sites
o.p 0 Posted February 3, 2010 Author Report Share Posted February 3, 2010 My code is#pragma bit load @ 5.0 ; // variable (load) is being assigned to the pin 0 Just drop the #pragma i.e. bit load @ 5.0 ; // variable (load) is being assigned to the pin 0 Check the reference manual for more info. Regards davidb Thanks david but it didnt work. There's nothing in the manual about this that I can see. Quote Link to post Share on other sites
davidb 0 Posted February 3, 2010 Report Share Posted February 3, 2010 o.p., It works on 16F & 18F but I must admit I haven't tried it on the PIC12F683. 'bit' is documented in the the BoostC manual V1.53 on page 45. Don't forget to set the port direction for the bit or bits you are trying to set to output i.e. trisio.5 = 0; Regards davidb Quote Link to post Share on other sites
o.p 0 Posted February 3, 2010 Author Report Share Posted February 3, 2010 o.p., It works on 16F & 18F but I must admit I haven't tried it on the PIC12F683. 'bit' is documented in the the BoostC manual V1.53 on page 45. Don't forget to set the port direction for the bit or bits you are trying to set to output i.e. trisio.5 = 0; Regards davidb Quote Link to post Share on other sites
o.p 0 Posted February 3, 2010 Author Report Share Posted February 3, 2010 Disregard my quote post, slip of the finger. I tried: bit load @ 5.0 ; The compiler seems to be ok with it. Alternatively I could create a GPIO char that acesses to the GPIO register and access each individual bit? ie char GPIO 5 ; GPIO.0 = 0; Although I dont think it likes variables to be the same name as registers, but not a big problem. ~o.p. Quote Link to post Share on other sites
Pavel 0 Posted February 4, 2010 Report Share Posted February 4, 2010 ...Although I dont think it likes variables to be the same name as registers, but not a big problem. ... That's because the identifiers you call "register names" are in fact defines located in system header files (try to comment out system.h include and this line will compile just fine). When you declare a variable like: char GPIO @ 5 ; C preprocessor will transform it into: char 0x0005 @ 5 ; and when this transformed line gets to the compiler it will report an error because it doesn't make sense from C language point of view. The convention used in BoostC system headers is: variable names in small and defines in capital letters. This is just a convention that could have been done differently but because most of C and C++ programmers outside of PIC world use it we decided to use it as well when we were creating system headers for BoostC. Regards, Pavel Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.