Here's the code to activate a loop that incraments the variable x by one each time then stops after x = 4. It's activated when a message has been sent from the blue smirf to the LCD through the pic. My partner precceeds all messages with a capital A to activate the serin command.
INCLUDE "modedefs.bas"
DEFINE OSC 20
INPUTDATA var byte
X VAR BYTE
X = 0
MAIN:
PORTB.5 = 0
SEROUT PORTB.1,T9600,[1]
WAITLOOP:
SERIN PORTA.1,T9600,[inputdata]
if inputdata <> "A" then goto waitloop
LOOP:
IF (X<4) THEN
HIGH PORTB.5
PAUSE 2
LOW PORTB.2
PAUSE 2
X = X+1
GOTO LOOP
endif
goto MAIN
This is a very simular code that activates the noise alert pulses constantly when the whearer of our device goes out of range then turns off when it comes back in range. It's activated by recieving a low at the input pin.
DEFINE OSC 20
TRISB.5 = 0
TRISB.4 = 1
X VAR BYTE
X = 0
START:
PORTB.5 = 0
IF PORTB.4 = 1 THEN GOTO START
IF PORTB.4 = 0 THEN GOTO LOOP
LOOP:
HIGH PORTB.5
PAUSE 2
LOW PORTB.5
Pause 2
IF PORTB.4 = 1 THEN GOTO START
GOTO LOOP
end
Did you set the OSC type in PBP *.inc file for this chip.
And if you did what did you set it for.
Or you can do it on this line that I do not see in the new code.
@ DEVICE MCLR_OFF, PROTECT_OFF, WDT_OFF,_XT_OSC
Double check the data sheet on this, I do not have it in front of me.
Dave
Always wear safety glasses while programming.
The guy use a 20MHz, so, should be something like HS_OSC instead of XT_OSC.
Anyways open the M16F88.inc file and enjoy the config fuse list
interesting this DEVICE2 option... for those using PMCode:; *** DEVICE Fuses Definitions EXTRC_OSC_CLKOUT equ 3FEC0013h ; XX XXXX XXX1 XX11 EXTRC_OSC_NOCLKOUT equ 3FEC0012h ; XX XXXX XXX1 XX10 EXTRC_OSC equ 3FEC0012h ; XX XXXX XXX1 XX10 INTRC_OSC_CLKOUT equ 3FEC0011h ; XX XXXX XXX1 XX01 INTRC_OSC_NOCLKOUT equ 3FEC0010h ; XX XXXX XXX1 XX00 INTRC_OSC equ 3FEC0010h ; XX XXXX XXX1 XX00 EXTCLK_OSC equ 3FEC0003h ; XX XXXX XXX0 XX11 EC_OSC equ 3FEC0003h ; XX XXXX XXX0 XX11 HS_OSC equ 3FEC0002h ; XX XXXX XXX0 XX10 XT_OSC equ 3FEC0001h ; XX XXXX XXX0 XX01 LP_OSC equ 3FEC0000h ; XX XXXX XXX0 XX00 WDT_ON equ 3FFB0004h ; XX XXXX XXXX X1XX WDT_OFF equ 3FFB0000h ; XX XXXX XXXX X0XX PWRT_ON equ 3FF70000h ; XX XXXX XXXX 0XXX PWRT_OFF equ 3FF70008h ; XX XXXX XXXX 1XXX MCLR_ON equ 3FDF0020h ; XX XXXX XX1X XXXX MCLR_OFF equ 3FDF0000h ; XX XXXX XX0X XXXX BOD_ON equ 3FBF0040h ; XX XXXX X1XX XXXX BOD_OFF equ 3FBF0000h ; XX XXXX X0XX XXXX LVP_ON equ 3F7F0080h ; XX XXXX 1XXX XXXX LVP_OFF equ 3F7F0000h ; XX XXXX 0XXX XXXX CPD_ON equ 3EFF0000h ; XX XXX0 XXXX XXXX CPD_OFF equ 3EFF0100h ; XX XXX1 XXXX XXXX WRT_1FOURTH equ 39FF0000h ; XX X00X XXXX XXXX WRT_HALF equ 39FF0200h ; XX X01X XXXX XXXX WRT_3FOURTHS equ 39FF0400h ; XX X10X XXXX XXXX WRT_OFF equ 39FF0600h ; XX X11X XXXX XXXX DEBUG_ON equ 37FF0000h ; XX 0XXX XXXX XXXX DEBUG_OFF equ 37FF0800h ; XX 1XXX XXXX XXXX CCPMX_ON equ 2FFF0000h ; X0 XXXX XXXX XXXX CCPMX_OFF equ 2FFF1000h ; X1 XXXX XXXX XXXX PROTECT_ON equ 1FFF0000h ; 0X XXXX XXXX XXXX PROTECT_OFF equ 1FFF2000h ; 1X XXXX XXXX XXXX ; *** DEVICE2 Fuses Definitions FCMEN_OFF equ 3FFE0000h ; XX XXXX XXXX XXX0 FCMEN_ON equ 3FFE0001h ; XX XXXX XXXX XXX1 IESO_OFF equ 3FFD0000h ; XX XXXX XXXX XX0X IESO_ON equ 3FFD0002h ; XX XXXX XXXX XX1X
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
My mistakeThe guy use a 20MHz, so, should be something like HS_OSC instead of XT_OSC.![]()
Dave
Always wear safety glasses while programming.
I know when I was in school, they always made us flow chart out the process first. Would you be able to do something like that for us, because honestly, I'm a little confused by your program.
some examples...
Originally Posted by AlaskanEE
Originally Posted by AlaskanEE
Code:'What is the value of inputdata the first time this runs? If you are using "A" for a qualifier, the statement should be SERIN PORTA.1,T9600,["A"],inputdata 'This statement will wait for until "A" comes in, then puts data after that into variable inputdataOriginally Posted by AlaskanEE
Did you ever get your hands on a PBP manual?Code:'I usually write IF X<4 THEN
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
I'm trying to get the backlight of my LCD to light when a voltage high is recieved on a pin from a push button circuit. I'm testing to see if I can send A to the LCD screen then have it pause then send a B every time I input a voltage high. The loop works and it sends serial data then pauses then sends serial data then goes back to outputing low voltage till a high is recieved again. The problem is that the LCD just is showing solid squares instead of the leters that I am trying to send. I've looked up the ASCII binary, decimal, and hexadecimal equivolents for A and B and sent the numbers with %, nothing, and $ preceeding the numbers equivolently all with the same result. Here's my code.
@ DEVICE MCLR_OFF, PROTECT_OFF, WDT_OFF
INCLUDE "modedefs.bas"
DEFINE OSC 20
DEFINE LCD_LINES 2
ANSEL = %00000000
TRISB.1 = 0
TRISB.0 = 1
WAITLOOP:
LOW PORTB.1
if PORTB.0 = 0 then goto waitloop
IF PORTB.0 = 1 THEN
serout PORTB.1,T9600,[65]
pauseus 14000
serout PORTB.1,T9600,[66]
ENDIF
goto WAITLOOP
this is the code with the decimal notation being used. I don't understand should I just try sending A i.e. serout portb.0,t9600,[A] or is that wrong as well?
If you are using a parallel mode LCD (Hitachi 44780 based), then PBP requires quite a few more defines to get it to work (see the manual).
If you are using a serial mode LCD (usually a parallel LCD mounted on a PCB with another PIC doing the decoding duties), then the DEFINE shown above isn't going to do anything for you. And you'll want to refer to the manual for the LCD.
And it would most likely help a lot if we knew what kind of LCD you were using...
Get the manual! And read it! We can help you with a lot of stuff...but again...I, for one, am not into hand-holding.
Last edited by skimask; - 26th April 2007 at 00:44.
OK... now we're on a different subject.
What type of LCD are you using? If it is a serial LCD, you don't need the following line.
If it is not a serial display and it has an HD44780 controller, you need some other LCD defines in there. But since I don't know, I'm going to assume it's a serial display. Next the serial part. Try...Code:DEFINE LCD_LINES 2
Next, the blocks on the LCD... try adjusting the contrast.Code:serout PORTB.1,T9600,["A"]
edit: Looks like Skimask was quicker on the draw. Ignore redundant information from me.
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
I'm sorry, earlier I copied down my old code that was rittled with errors and didn't have the input and outputs set. Here is the new code:
INCLUDE "modedefs.bas"
DEFINE OSC 20
ANSEL = %00000000
INPUTDATA var byte
TRISA.2 = 1
TRISB.2 = 0
PORTA.2 = INPUTDATA
X VAR BYTE
X = 0
MAIN:
PORTB.2 = 0
WAITLOOP:
SERIN PORTA.2,T9600,[inputdata]
if inputdata <> "A" then goto waitloop
LOOP:
IF X<4 THEN
HIGH PORTB.2
PAUSE 2
LOW PORTB.2
PAUSE 2
X = X+1
GOTO LOOP
endif
goto MAIN
I want pin A.2 to be the input from the bluesmirf, which will be sending messages to our LCD via serial ports. The serial data will come into the pic through porta.2. Each message that is sent by the bluesmirf will be proceeded by the letter A. I'd like porta.2 to not accept any random data and only activate the loop when a message is recieved that is preceeded by the letter A. The output should be a high then low loop that loops four times. The output should come from portb.2
The LCD we're using is the serial enabled LCD SerLCD v2.5 it's default settings are 9600 bps with eight bits of data, 1 start bit, 1 stop bit, and no parity. I wasn't sure of the DEFINE LCD_LINES 2 command, but I figured it couldn't hurt since our LCD is 2 lines, and since the LCD is a serial input I didn't think I needed any of the LCDIN/LCDOUT commands.
yeah I forgot the quotes on A. It all made sense in my mind, if you could just stop being selfish and start reading other peoples minds this would be much easier![]()
Ok, give this a try...
Code:INCLUDE "modedefs.bas" DEFINE OSC 20 ANSEL = %00000000 INPUTDATA var byte TRISA.2 = 1 TRISB.2 = 0 '''''''PORTA.2 = INPUTDATA 'don't need this line X VAR BYTE X = 0 MAIN: PORTB.2 = 0 WAITLOOP: SERIN PORTA.2,T9600,["A"],inputdata '''''''''''if inputdata <> "A" then goto waitloop ' don't need this line LOOP: IF X<4 THEN HIGH PORTB.2 PAUSE 2 'Question here... do you really want to pause for 2 milliseconds? LOW PORTB.2 PAUSE 2 'same question here X = X+1 GOTO LOOP endif goto MAIN
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
I made an earlier post asking about that. I'm using an external oscilator set up with a 20MHz oscillator and with the input and out puts going through 47uF capacitors to ground and their perspective input and output oscilator pins on the PIC. When I used PAUSE 500 for a half second pause, it paused for a lot longer than half a second. I lowered it down to 2 and it paused for about a second so I just went with it and just posted a question about it on here
Bookmarks