Thanks Dave - that seems to have solved my problem.
Now to move on to the LCD display section followed (hopefully) soon after by the A/D section.
Cheers
Barry
Thanks Dave - that seems to have solved my problem.
Now to move on to the LCD display section followed (hopefully) soon after by the A/D section.
Cheers
Barry
COOL!!!
Keep the data sheet handy![]()
Dave
Always wear safety glasses while programming.
Things are progressing well with the extension of my project but I have hit a bit of a snag.
I have the the A/D working on PORTB.0 and I can do all the standard "Hello World" type stuff with the LCD. My problem occurs when I try to display the result of the A/D conversions.
The relevant code extract is as follows:
adval var byte ' Create adval to store result
ADCON0 = %11110001 ' Set clock divisor to INTOSC/4
' Set AN0, AN1 and AN2 as Analogue Input
' Turn on A/D converter
CM1CON0 = 0 ' Disable comparator
CM2CON0 = 0 ' Disable comparator
OPTION_REG.5 = 0 ' Set PORTC.5 as digital I/O port
TRISC = 0 ' Set PORTC as all outputs
TRISB = %00000111 ' Set PORTB.0, PORTB.1 and PORTB.3 as inputs
Pause 500 ' Wait .5 second
loop: ADCIN 0, adval ' Read channel 0 to adval
LCDOUT $fe, 1 ' Clear LCD
LCDOUT "Value: ", DEC adval ' Display the decimal value
Pause 100 ' Wait .1 second
Goto loop ' Do it forever
End
When I try to compile this program using MPLAB IDE I get the following error
Executing: "C:\PBP\PBPW.EXE" -ampasmwin -oq -z -p16F506 "ADCIN8 16F506.bas"
PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc.
All Rights Reserved.
ERROR: Macro LCDOUTCOUNT?C not found in macro file.
ERROR: Macro LCDOUTNUM?B not found in macro file.
ERROR: Macro LCDOUTDEC? not found in macro file.Halting build on first failure as requested.
BUILD FAILED: Mon Jan 17 21:22:24 2011
but when I change the LCDOUT statement to
LCDOUT "Value: ", #adval
everything works perfectly.
I was led to believe that the two statements are the same so why doesn't it work?
Frustratingly, LCDOUT "Value: ", DEC adval works perfectly when compiling fo 16F684 or 16F716 but not 16F506.
Can anyone shed some light on this?
The final program will use Darrel Taylor's Bargraph display and my initial compile resulted in a host of LCDOUT error statements (DEC, REP issues) so I need to get to the bottom of this problem. (BTW, I can get Darrel's bargraph working beautifully on 16F684, 16F716 etc).
Cheers
Barry
SEROUT2 type modifiers aren't supported for 12-bit core device types.
WOW!
I don't ever remember seeing that documented anywhere.
Thanks Bruce.
I guess that kills it for the 16F506 on this project...
Cheers
Barry
It's in the 2nd paragraph in the manual under LCDOUT, and in older versions of PBP new.txt docs.
12-bit core has very limited support due to limited resources on the PIC. If you're using these, it's best to keep it as simple as possible since these device types have very limited RAM and stack resources.
You can normally find a 14-bit core type really close to same price range.
Thanks Bruce,
I don't know how many times I have read the LCDOUT section of the manual without seeing that caveat (or at least have it sink into my brain). A valuable lesson learnt!.
I will change over to using a PIC16F684 - pin compatible, does what I need it to do and is less than a dollar more expensive.
Thank you to all who have assisted me in my endeavours.
Cheers
Barry
Bookmarks