You do have to use the pre-assigned variables as mentioned here or use this at the beginning:
i symbol B0
to assign your own name to the variable.
Bart
You do have to use the pre-assigned variables as mentioned here or use this at the beginning:
i symbol B0
to assign your own name to the variable.
Bart
Hello tekdavid,
TD>>12: i VAR byte
13: for i = 1 to 4
14: high 0
15: pause 1000
16: low 0
17: next i<<
I also question lines 14 and 16...
Usually it is a High Porta.0 or Low Porta.0 or
it may be High Portb.0 or Low portb.0
Either way, It might be good to assign a port to it.
Another problem... What do your lines BEFORE line 12 look like?
Sometimes the compiler may flag line 12, but the problem is actually
in line 10 or 11....
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
I think it's the illegal (undeclared) variable 'i' in this case Dwayne...
High 0 and Low 0 are valid for addressing pin 0 of your PIC (note that which physical pin that pin 0 refers to is dependant of the PIC family - refer to the PICBasic manual for that).
Hello Melanie,
Melanie>>High 0 and Low 0 are valid for addressing pin 0 of your PIC (note that which physical pin that pin 0 refers to is dependant of the PIC family - refer to the PICBasic manual for that).<<
Gotcha...I wasn't sure which pic they were using...
I always seem to get myself into trouble if I don't spell it out <smile>.. Thus I kinda do things the "long Hand" way...GPIO.0, Porta.0, or whatever. Its kinda like those headers at the beginning of your file, If it is already defined for your chip, it can save *ME* a lot of time trying to figure out why my compiler is burping at me.
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
You really must try to avoid coding GPIO.0 or PortA.0 (or similar) in your programs... I'll tell you why... you have fifteen instances in a thousand lines of code where you refer to a particular pin... Firstly - just get ONE of those instances wrong and your code is screwed... but you'll never know it until that particular piece of code is executed. Secondly - you're laying out your PCB and you discover it's easier to place your components and lay your tracks if you swapped pins PortA.5 with PortB.6. You now spend half a day trying to find all the references to those pins in your program and worry about swapping them over.Thus I kinda do things the "long Hand" way...GPIO.0, Porta.0, or whatever.
There is a better way...
At the start of your program, right after you've done all your Config Fuse Defines, you have a section where each and every pin on your PIC is defined (aliased), and you ONLY use those aliases in your program... example - a snip out of a program that uses a PIC16F876...
Now, if I have to amend my program, and turn my Red LED on, rather than try to remember what pin my Red LED is connected to, I simply say...Code:' ' Hardware Defines ' ================ ' ' LCD Display ' ----------- Define LCD_DREG PORTC ' Port for LCD Data Define LCD_DBIT 4 ' Use upper 4 bits of Port Define LCD_RSREG PORTC ' Port for RegisterSelect (RS) bit Define LCD_RSBIT 3 ' Port Pin for RS bit Define LCD_EREG PORTC ' Port for Enable (E) bit Define LCD_EBIT 0 ' Port Pin for E bit Define LCB_BITS 4 ' Using 4-bit bus Define LCD_LINES 2 ' Using 2 line Display Define LCD_COMMANDUS 2000 ' Command Delay (uS) Define LCD_DATAUS 50 ' Data Delay (uS) LCDBackLight var PORTC.1 ' LCD Backlight PWM Pin LCDContrast var PORTC.2 ' LCD Contrast PWM Pin ' ' Sensor Inputs ' ------------- PressIN var PortA.0 ' Pressure Transducer Input ' ' Button (Internet) Inputs ' ------------------------ ButtonDown var PortB.0 ' SW2/Button DN ButtonUp var PortB.1 ' SW1/Button UP ButtonSet var PortB.2 ' SW3/Button SET/RST ButtonReserve var PortB.7 ' SW4/Exclusive CPU Access Button ' ' System Outputs ' -------------- GreenLED var PortA.1 ' Green LED RedLED var PortA.2 ' Red LED Beeper var PortA.3 ' Piezo Sounder ' ' Communications I2C Bus ' ---------------------- SCL var PortA.4 ' I2CLock SDA var PortA.5 ' I2CData ' ' Communications Inter-Processor (IP) Bus ' --------------------------------------- IPAEnable var PortB.3 ' IPENABLEA IPBEnable var PortB.6 ' IPENABLEB IPClock var PortB.4 ' IPCLOCK IPData var PortB.5 ' IPDATA
High RedLED
and if I'm laying out my PCB and need to shuffle the pins about for convenience, there's just one section I need to look in to make changes globally in my program.
And better still, if I need to port my program to a different PIC, again, just one section reassigns all the pins.
Get in the habit of doing it this way - it will save you countless HOURS in the long term.
Bookmarks