PIC16F88 senior design


Closed Thread
Results 1 to 40 of 72

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    21

    Default

    I thought I might have burnt out my PIC so I started trying very basic commands to test it out. Just output a voltage high on one pin when there's a voltage high on the input pin. This is the code I used:

    DEFINE OSC 8
    TRISA.1 = 1
    TRISA.2 = 0
    LOOP:
    IF PORTA.1 = 1 THEN HIGH PORTA.2
    GOTO LOOP

    END

    I used a VDD of 5V and got an output of 5V at A.2 but sometimes it will suddenly drop to 0 volts without me adjusting anything. I remove the pic from the circuit and then put it straight back in and the output is at 5V again. Sometimes the voltage stays for a while sometimes it goes away rapidly. Does it sound like my PIC might be faulty? or is there a problem in my code. Also if the PIC is outputing a high and I remove the high input I would expect the output to drop as well, but it doesn't. Do I need to include a second IF, THEN statement to achieve this result?

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    DEFINE OSC 8
    TRISA.1 = 1
    TRISA.2 = 0
    LOOP:
    IF PORTA.1 = 1 THEN HIGH PORTA.2
    GOTO LOOP

    END

    Also if the PIC is outputing a high and I remove the high input I would expect the output to drop as well, but it doesn't. Do I need to include a second IF, THEN statement to achieve this result?
    If you read the code inside your 'LOOP', there's nothing there to tell the pin to go low if the input goes low...therefore...

    DEFINE OSC 8
    TRISA.1 = 1
    TRISA.2 = 0
    LOOP:
    PORTA.2 = PORTA.1
    GOTO LOOP

    Also, check your datasheet regarding PortA and analog settings, section 12.0 of the PIC16F88 datasheet. You might see something there that might throw a wrench into your master plan!

  3. #3
    Join Date
    Apr 2007
    Posts
    21

    Default

    I switched up to using B.1 as an input and B.2 as an output along with the portb.1=portb.2 and it worked well. After about 13 seconds, however, it stops working. Is this due to the fact that I'm relying on the internal oscilator or is there additional code that I don't know about. Also I looked over 12.0 and I see that PORT A pins would need additional lines of code to work, but I'm not fully understanding what their saying. Do the pins for PORTA have to be used for A/D conversion?

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    I switched up to using B.1 as an input and B.2 as an output along with the portb.1=portb.2 and it worked well. After about 13 seconds, however, it stops working. Is this due to the fact that I'm relying on the internal oscilator or is there additional code that I don't know about.
    Common stuff:
    Pullup on MCLR to Vdd?
    .1uf cap across Vdd and Vss?
    Power supply solid and smooth?
    WDT config set to Off?

    Also I looked over 12.0 and I see that PORT A pins would need additional lines of code to work, but I'm not fully understanding what their saying. Do the pins for PORTA have to be used for A/D conversion?
    Keep reading past the first couple of paragraphs, read all about the registers relating to the A/D converter and the ports...You'll figure it out.

  5. #5
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216

    Default

    AlaskanEE -
    Hint....
    Read Section 12.0 as Skimasks suggests, review table 12-1. Now go to pg. 52 and review table 5-2. Look at the column that tells you what the POR, BOR and value after all other resets is. What does it tell you about the default setting of the registers in table 12-1?
    Here's another good tool. Use this LINK to search the forums. It seems to work better than the built in search tool.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

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

    Default

    Dave
    Always wear safety glasses while programming.

  7. #7
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by mackrackit View Post
    These are in the FACT section.
    True that they are FACTs, but don't you mean FAQ section?

Similar Threads

  1. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  2. pic16f88 & voltage
    By rdxbam in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th February 2009, 09:14
  3. Ghange code from PIC16F877A to PIC16F88
    By savnik in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th March 2008, 16:09
  4. Replies: 8
    Last Post: - 7th December 2006, 15:42
  5. PIC16F88 problem with TOGGLE command?
    By russman613 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th September 2006, 23:31

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