PIC16F506 Problems


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166

    Default PIC16F506 Problems

    Hi All,

    I am having some difficulties running anything on a PIC16F506.
    The intended project was to display some information on a 16x2 LCD display but after I couldn't get that to work I went back to basics and tried a simple "Blink" program. I have tried the following code using an external (crystal) oscillator as well as the internal oscillator but get absolutely nothing happening on the LED. (the LED circtuit works perfectly when connected/driven manually)

    Led var PORTC.0
    TRISC=0
    Again:
    Led=1
    Pause 1000
    Led=0
    Pause 1000
    Goto Again
    end

    I am quite confused as to why this simple program will not work on the 16F506 when I can get it to work on others (eg 16F84A, 16F628A, 16F716 tec.)

    Is there something peculiar about using the 16F506 that I am missing?

    Any help would be greatly appreciated.

    Cheers
    Barry

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    That chip has comparators that need turned off when not using them.
    Try adding near the top of your code
    CM1CON0 = 0
    CM2CON0 = 0
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    COOL!!!
    Keep the data sheet handy
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    SEROUT2 type modifiers aren't supported for 12-bit core device types.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  9. #9
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts