16F88 ADC problem


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Location
    British Columbia, Canada
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help first of all.

    I've rewritten the code and connections as per the example in the picbasic pro manual.

    Works great on the 16F627A, now to port it over to the 16F88.

    I'll post the results when it's done.

    '************************************************* ***************
    '* Name : LCDTest1.pbp *
    '* Author : Greensasquatch *
    '* Notice : Copyright (c) 2008 greensasquatch.ca *
    '* : All Rights Reserved *
    '* Date : 05/09/2008 *
    '* Chip : PIC16F627A *
    '* Version : 1.1 *
    '* Notes : Send Hello World to a LCD on PORTB pins *
    '* : blink a LED connected to RB6 as a status light *
    '************************************************* ***************
    '* PicBasicPro program to demonstrate *
    '* operation of an LCD in 4-bit mode. *
    '************************************************* ***************
    '*
    '* Connections are as follows:
    '*
    '* N/C -01-|####|-18- N/C
    '* N/C -02-|####|-17- N/C
    '* N/C -03-|####|-16- N/C
    '* N/C -04-|####|-15- N/C
    '* Gnd -05-|####|-14- V+
    '* E on LCD on RB0 -06-|####|-13- RB7, LCD Pin DB7
    '* RS on LCD on RB1 -07-|####|-12- RB6, LCD Pin DB6
    '* N/C -08-|####|-11- RB5, LCD Pin DB5
    '* red LED on RB3 -09-|####|-10- RB4, LCD Pin DB4
    '*
    '************************************************* ***************

    INCLUDE "MODEDEFS.BAS"

    @ DEVICE pic16F627A, INTRC_OSC_NOCLKOUT, MCLR_OFF

    ' Set LCD Data port
    DEFINE LCD_DREG PORTB
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 4
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTB
    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 1
    ' Set LCD Enable port
    DEFINE LCD_EREG PORTB
    ' Set LCD Enable bit
    DEFINE LCD_EBIT 0
    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    ' Set command delay time in us
    DEFINE LCD_COMMANDUS 2000
    ' Set data delay time in us
    DEFINE LCD_DATAUS 50


    'LED Connected to PortB.3 to circuit is doing something
    LED var PORTB.3
    output PORTB.3

    CMCON = 7 'Turn off comparators
    Pause 2000 ' Wait for LCD to startup

    loop: toggle LED
    Lcdout $fe, 1 ' Clear LCD screen
    Pause 500 ' Wait .5 second
    Lcdout "Greensasquatch" ' Display Greensasquatch on 1st line
    Pause 500 ' Wait .5 second
    toggle LED
    Lcdout $fe,$c0,"Hello" ' move cursor to 2nd line, display Hello
    Pause 1000 ' Wait 1 second
    toggle LED
    Lcdout $fe,$c0,"World" ' move cursor to 2nd line, display World
    Pause 1000 ' Wait 1 second
    toggle LED
    Goto loop ' Do it forever
    -Justin

  2. #2
    Join Date
    Aug 2008
    Location
    British Columbia, Canada
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Progrss report...

    So I've now got a new problem, can you tell I'm a noob yet?

    I've created a program now to make sure the 16F88 is working ok.

    I load the program in to the pic, compile, burn and it works. LED flashes away merrily.

    My problem now is that I can no longer reprogram the chip.

    If I connect my JDM programmer to the serial port I can detect the programmer with PICPgm and if i then insert the chip I can detect it. BUT when I try to burn the new hex file it immediately says No chip found, and then no programmer found.

    I'm wondering if it has something to do with using the RA6 and RA7 pins that are normally OSC pins. It almost seems like the programmer is fine until the PIC gets power and starts doing it's blink code. (just guessing, I'm really new at this and grasping at straws).

    Any suggestions?

    the code in case that helps:

    '************************************************* ***************
    '* Name : 88Blinker.pbp *
    '* Author : Greensasquatch *
    '* Notice : Copyright (c) 2008 *
    '* : All Rights Reserved *
    '* Chip : PIC16F88 *
    '* Date : 06/09/2008 *
    '* Version : 1.0 *
    '* Notes : To set up the most basic settings to flash *
    '* : an LED on a PORTB pin using only the internal *
    '* : oscillator and MCLR turned off. *
    '* : *
    '************************************************* ***************
    '*
    '* Connections are as follows:
    '*
    '* RA2 -01-|######|-18- RA1
    '* RA3 -02-|######|-17- RA0
    '* RA4 -03-|######|-16- RA7 to LED
    '* RA5 -04-|######|-15- RA6 to LED
    '* Gnd -05-|######|-14- V++
    '* RB0 -06-|######|-13- RB7
    '* RB1 -07-|######|-12- RB6
    '* RB2 -08-|######|-11- RB5
    '* RB3 -09-|######|-10- RB4
    '*
    '************************************************* ***************

    OSCCON = $60 'set int osc to 4mhz
    ANSEL = 0 'ALL DIGITAL
    CMCON = 7 'COMPARATORS OFF

    TRISA = %00000000 'all output
    TRISB = %00000000 'all output
    PORTA = 0 'all porta low

    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON
    Pause 100 'wait to start

    START:
    High PORTA.6 'LED's on
    High PORTA.7
    Pause 1000
    Low PORTA.6 'LED's off
    Low PORTA.7
    Pause 1000
    GoTo START 'repeat
    -Justin

  3. #3
    Join Date
    Aug 2008
    Location
    British Columbia, Canada
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I've been going over my code line by line. Finally found something odd. And I've come to the conclusion that this is the last time I copy lines from somebody else's code.

    I'm sure the line <b>PROTECT_ON</b> is the reason i can no longer use this chip.

    I got lazy and copied
    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON
    from someone else's 16f88 project without actually reading what it was set to do.

    I'll have to wait until next week when my new 16F88 chips get here I think that one is now toast. Lesson learnt.

    Thanks to everyone who helped, I'll post updates when I resume the project.
    -Justin

  4. #4
    sinoteq's Avatar
    sinoteq Guest


    Did you find this post helpful? Yes | No

    Default Protect_On

    Hi
    The chip you are using is a flash based PIC and it can be programmed many times. I don't think I have ever heard of a PIC that has been programmed too many times.

    Your problem is a different one I think. Because you use INTRC_OSC and MCLR_OFF the internal Oscilator is used in the PIC and when you try to program the chip it has already started exectution of the internal Flash program you put there the first time. Your programmer can not access the chip in this case.


    Please look at http://www.picbasic.co.uk/forum/showthread.php?t=5465
    or http://www.picbasic.co.uk/forum/showthread.php?t=7616

    and you see some more info about this problems.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sinoteq View Post
    Your problem is a different one I think. Because you use INTRC_OSC and MCLR_OFF the internal Oscilator is used in the PIC and when you try to program the chip it has already started exectution of the internal Flash program you put there the first time. Your programmer can not access the chip in this case.

    Please look at http://www.picbasic.co.uk/forum/showthread.php?t=5465
    or http://www.picbasic.co.uk/forum/showthread.php?t=7616

    and you see some more info about this problems.
    Hey...Good Point!
    I especially like post #12 of the 2nd link...
    Seems like I end up suggesting the same thing over and over again...

  6. #6
    Join Date
    Aug 2008
    Location
    British Columbia, Canada
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Sinoteq,
    thanks for the links. I'm thinking I should stop being so cheap and just get a programmer from microchip now. This JDM just doesn't seem to do everything I want it to do.

    Skimask,
    I have erased the chip using WinPic (or at least winpic thinks it's erasing the chip, I get no errors) but when i try to reprogram I get verify errors.

    I'm going to go back to tinkering with my 16F627A's and RF for a while until I get another 16F88. I'll stay away from using INTRC_OSC and MCLR_OFF together for now.

    At least I know what happened to my 12F675's now, too bad I bent the pins and tossed them.

    You guys are great, thanks again.
    -Justin

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by greensasquatch View Post
    I'm thinking I should stop being so cheap and just get a programmer from microchip now.
    You won't be sorry when you get it... I can guarantee it...

    Skimask,
    I have erased the chip using WinPic (or at least winpic thinks it's erasing the chip, I get no errors) but when i try to reprogram I get verify errors.
    I think that 1st link in post 11 above has the information you need to modify your programmer to get it all to work.

    At least I know what happened to my 12F675's now, too bad I bent the pins and tossed them.
    Drill holes in them and turn them into geek jewelry!

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by greensasquatch View Post
    Sinoteq,
    thanks for the links. I'm thinking I should stop being so cheap and just get a programmer from microchip now. This JDM just doesn't seem to do everything I want it to do.

    Skimask,
    I have erased the chip using WinPic (or at least winpic thinks it's erasing the chip, I get no errors) but when i try to reprogram I get verify errors.

    I'm going to go back to tinkering with my 16F627A's and RF for a while until I get another 16F88. I'll stay away from using INTRC_OSC and MCLR_OFF together for now.

    At least I know what happened to my 12F675's now, too bad I bent the pins and tossed them.

    You guys are great, thanks again.
    I have 2 JDM programmers, they are different from one another, on each of them, printed on the circuit board is the orientation of the pic chips and location, As I said, they are WAY different in respect to each other. as far as issues of MCLR on/off, INTRC vs HS, xt . . . NONE. The issue I seem to have is one of them the ZIF socket is beginning to wear (the Plating) and I got tired of having to wiggle the chips before programming, that's why I have 2. #2 came in the mail today, works fine so far using ICProg.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by greensasquatch View Post
    ...
    I have erased the chip using WinPic (or at least winpic thinks it's erasing the chip, I get no errors) but when i try to reprogram I get verify errors.

    I'm going to go back to tinkering with my 16F627A's and RF for a while until I get another 16F88. I'll stay away from using INTRC_OSC and MCLR_OFF together for now.
    I have an MELabs programmer, and I've been very happy with it. The tech support is great, too. I had a chip with the same issue as you, so I called and asked about it. They said that the programmer relies on MCLR to program it--and since you turned it off, there is an issue. If you need to make that pin an output, you need a 1-2 second delay before setting the Tris. This might not be your exact issue since some of your settings were pasted from elsewhere, but it is something to keep in mind.

    BTW, it's nice when the tech support for your hardware and software come with the same phone call.

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by greensasquatch View Post
    I've been going over my code line by line. Finally found something odd. And I've come to the conclusion that this is the last time I copy lines from somebody else's code.

    I'm sure the line <b>PROTECT_ON</b> is the reason i can no longer use this chip.
    If PROTECT_ON is used, that means you can't READ the chip, doesn't mean you can't write to it.
    ERASE the chip completely...then reprogram it...

Similar Threads

  1. PIC18F2423, ADC problem
    By mistergh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th March 2009, 01:31
  2. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 17:47
  3. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 21:22
  4. Problem with 16F88 controlling h-bridges
    By silentwol in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th March 2007, 04:16
  5. 16F88 using comparators AND the adc
    By jpeakall in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th May 2005, 01:08

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