PICBASIC PRO program for I2C slave program - PIC16F877/PIC-X1. Lcd.pbp: PICBASIC PRO program to demonstrate operation of an LCD in 4-bit mode. Logic.pbp: PICBASIC. PicBasic PRO Examples. These examples are designed to demonstrate how to use a PIC16F877 and PicBasic PRO to communicate with our modules, most of these examples use. PBP is a mature BASIC compiler for Microchip's PIC microcontrollers. Its licensed user base of 10,000+ is composed mostly of engineers and companies. It is intended to be a professional development tool, though its painless syntax also makes it a favorite among hobbyists and institutions of learning. PICBasic and PICBasic Pro Examples. Connect the serial input of the LCD to PortB.0 (pin 6) of a PIC Microcontroller. The following PIC Basic program demonstrates.
Serial comunication can be annoying (custom cable connections, RS232 to TTL voltage levels, baud rates, etc). Use a feedback loop (connect serial port's 'out' pin with the 'in' pin) and hyperterminal (free prog that comes with windows) to test your computer's serial output before you try to connect to external electronics (like the PIC). Yeah, I guess I'm self taught, I started with BasicStamps and worked up to PICs when the basic stamp wasn't good enough for my projects. The PIC code is just in PICBasic, not assembly language. It would be really long and messy if it was in assembly.
They do have assembly language interupt code examples in the PICBasic manual though. Post Comment.
PICBasic and PICBasic Pro Examples Connect the serial input of the LCD to PortB.0 (pin 6) of a PIC Microcontroller. The following PIC Basic program demonstrates sending data and commands to the LCD: main: pause 1000 ' wait for the LCD to startup serout 0,T2400,($FE,$01) ' clear the screen serout 0,T2400,('Wherever you go') ' send the string “wherever you go' serout 0,T2400,($FE,$C0) ' move the cursor to the second line serout 0,T2400,(' there you are ') ' send the string “ there you are “ pause 1000 ' wait one second goto main ' do it again The program will clear the LCD and send the message: “Wherever you go, there you are” at 2400 baud (true mode), wait for two seconds and then loop indefinitly. Note that in the above example, the control codes were written in hexidecimal (base 16). Hexidecimal is specified by a dollar sign ($) prefix. If you wish, the lines: serout 0,T2400,($FE,$01) ' clear the screen serout 0,T2400,($FE,$C0) ' move the cursor to the second line Could also be written with decimal (base 10) notation as: serout 0,T2400,(254,1) ' clear the screen serout 0,T2400,(254,192) ' move the cursor to the second line Which notation you choose to use is a matter of preference. An equivalent program can be written with PIC Basic Pro as follows: main: pause 1000 ' wait for the LCD to startup serout PortB.0,0,[$FE,$01] ' clear the screen serout PortB.0,0,['Wherever you go'] ' send string “Wherever you go” serout PortB.0,0,[$FE,$C0] ' move the cursor to the 2nd line serout PortB.0,0,[' there you are '] ' send string “ there you are ” pause 1000 ' pause for a second goto main ' loop Printing Variables in PICBasic and PICBasic Pro Say you have a variable, foo, in which some number is stored. Nfs The Run Patch 1.1. In PIC Basic, foo would be declared like so: symbol foo = B0 In PIC Basic Pro, foo would be declared: foo var byte The serout command, when given a variable, will by default print the character which is represented by the number stored in the variable and not the value of the variable itself.
If you want to print the number inside the variable, you must prefix the variable name with a pound sign (‘#’). For example, if the value of foo was 65: serout 0,T2400,(foo) ' PICBasic, prints ‘A’ character serout 0,0,[foo] ' PICBasic Pro, prints ‘A’ character The above example would not print “65” on the display, but meerly the ascii character ‘A’ (capital A). Look at an ASCII decimal to character chart -- the ASCII representation of the number “65” is ‘A’! Likewise, if foo was 66, a ‘B’ would have been printed, etc. While this may be desirable for some applications, most would simply want the “65” to print and not it’s ASCII equivalent. To do accomplish this -- that is, to print a variable foo in numeric form -- we prefix the varaible with a pound sign, as noted above: serout 0,T2400,(#foo) ' PICBasic, prints “65” serout 0,0,[#foo] ' PICBasic Pro, prints “65” Dimensions and Specifications • 16 characters x 2 lines • High-contrast supertwist display • LED Backlight • Accepts RS232, inverted or true TTL / CMOS at 300, 1200, 2400 and 9600 bps. • Power Requirment: 4.8 - 5.2 VDC, approx.
40 mA • Size: 3.1' L x 1. Calman Studio 5 Cracked Heels. 4' W • Weight: 0.1 lbs.