ilmenator Posted July 11, 2008 Report Posted July 11, 2008 I am using J5 as digital output for a number of control signals. As these signals might be located on other pins in the future (depending on the hardware design), I would like to design my code such that the "pin mapping" can easily be reconfigured in the future.So, instead of writing PORTAbits.RA2 = 1; I would prefer something like Clk_LData = 1; with Clk_LData being the name of the signal. I'm still no programmer, but would something like ///////////////////////////////////////////////////////////////////////////// // Global definitions ///////////////////////////////////////////////////////////////////////////// #define Clk_LData PortAbits.RA1 in main.h do what I want? It compiles okay, but I am without hardware right now and cannot properly test it...Thanks a lot, ilmenator Quote
stryd_one Posted July 11, 2008 Report Posted July 11, 2008 Works fine :)If you want to be sure - have a look in _output/*.asm and see what it makes in ASM. You should see like this: #define Clk_LData PortAbits.RA1 Clk_LData = 1; bsf PORTA,1 Quote
ilmenator Posted July 11, 2008 Author Report Posted July 11, 2008 Great, thanks![edit: I had a typo in my code that gave a nice little error... hence a bit of confusion with some discussion in the chat :)] Quote
stryd_one Posted July 11, 2008 Report Posted July 11, 2008 So yes, as per the chat, the variables are case-sensitive, so we need "PORTAbits.RA1" :)Typos suck. I always forget the semicolons at the end of the line. I mean like aaaaaall the time, maybe one in every 50 lines I write..... I dunno what's wrong with my brain :DFor those not in the chat:[stryd_one] 12:13 am: illy hot tip for ya (i'll put this in the thread too)[stryd_one] 12:13 am: sdcpp is your friend[stryd_one] 12:14 am: you can run the preprocessor standalone to see what your code outputs[stryd_one] 12:14 am: and that's what i'm about to do right now [stryd_one] 12:17 am: i create test.c: #define Something PORTAbits.RA1 Something=1; [stryd_one] 12:18 am: that's all just the two lines.. you can do it with the whole file if you want, it doesn't alter it [stryd_one] 12:19 am: then I run sdcpp (Small Device C PreProcessor...what handles the defines and #ifs and such) against the file: C:\Temp>sdcpp test.c # 1 "test.c" # 1 "<built-in>" # 1 "<command line>" # 1 "test.c" PORTAbits.RA1=1; C:\Temp> [stryd_one] 12:19 am: works like a charm [stryd_one] 12:20 am: btw, you can output to a file like this: sdcpp <yourfile.h> -o <output filename> [stryd_one] 12:21 am: sdcpp --help will show you a billion pages of optionsHTH! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.