I am trying to use the same program for different microprocessors. I tried the following code, but the compiler picked up the code from the second chip, even though I said to use the first block. Is there some limitation on #if I'm not understanding? I determined it was picking up the second block by looking in the asm file produced, it clearly call initpps2.
I dont think you can do that the compiler looks for one #chip line. This could work as an approach but it does not as you cannot not substitute a constant on the chip line.
Look at what is shown below but in the context that the chipname substitution does not work.
I thought I might tackle it the opposite direction and just define the wanted chip with the correct #chip 16F18324,32 at the top and just test
by using #if ChipNameStr="16F18324" , but the #if always fails. I guess ChipNameStr isn't available yet at that point in the compilation where #if is evaluated?
This is not a big deal, Evan. I was just trying to clean up my code a little.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not much help I'm afraid other than to say that when I was trying to do something similar I wrote two 'definition blocks' and commented one or the other out like this:
#DefineUse1459#Chip16F1459,48#ConfigOSC=INTOSC,PLLEN=On#DefineLCD_RSPortA.5'A.0 and A.1 are In only on the 1459#DefineLCD_EnablePortA.4'so use A.5 and A.4 which are opposite'#Define Use1829'#Chip 16F1829, 32'#Define LCD_RS PortA.0'#Define LCD_Enable PortA.1
I am trying to use the same program for different microprocessors. I tried the following code, but the compiler picked up the code from the second chip, even though I said to use the first block. Is there some limitation on #if I'm not understanding? I determined it was picking up the second block by looking in the asm file produced, it clearly call initpps2.
I dont think you can do that the compiler looks for one #chip line. This could work as an approach but it does not as you cannot not substitute a constant on the chip line.
Look at what is shown below but in the context that the chipname substitution does not work.
Let me look into this.
I thought I might tackle it the opposite direction and just define the wanted chip with the correct #chip 16F18324,32 at the top and just test
by using #if ChipNameStr="16F18324" , but the #if always fails. I guess ChipNameStr isn't available yet at that point in the compilation where #if is evaluated?
This is not a big deal, Evan. I was just trying to clean up my code a little.
Not much help I'm afraid other than to say that when I was trying to do something similar I wrote two 'definition blocks' and commented one or the other out like this:
Then within the code used stuff like this:
Which I'm sure you have worked out for yourself anyway...