Newb Question...


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2008
    Posts
    21

    Default Newb Question...

    For starters: MPLab 8.10, ICD2, PIC12F629, PBP 2.50a
    Initializations

    Include "modedefs.bas"

    trisio =%110000

    red var gpio.0 'red
    blue var gpio.1 'blue
    buzzer var gpio.2 'buzzer
    Contact var gpio.4 'Input1
    Contact1 var gpio.5 'Input2
    i var byte 'general counter
    k var byte 'general counter


    My initializations stay the same for all below.



    main:
    red=0
    blue=1
    pause 500

    blue=0
    red=1
    pause 500

    goto main


    This code alternates a red and blue LED as expected. Good.







    main:
    red=0
    blue=1
    pause 500

    red=1
    blue=0
    pause 500

    goto main

    This code... blue light comes on... blue light goes off(red doesnt come on). Not good. Shouldnt they alternate???



    main:
    blue=1
    red=0
    pause 500

    red=1
    blue=0
    pause 500

    goto main

    This code... nothing happens. ??? Shouldnt they alternate


    main:
    blue=1
    red=1
    pause 500

    goto main

    This program results in only red. I think it should result in both?





    The above programs and results were done in my 12f629. This is my first time with such a weak PIC, but its job is super simple and its the cheapest and smallest PIC we stock here. I put the same code into my 18F2520 and 4520s and they act as I would expect they act. Could someone explain to me why it appears to be only taking the last variable I use, be it red or blue and using that one. Am I expecting something wrong? If so why are my expectations correct for the 2520 series?






    So I've been programming with PBP for quite a while now, about 6 months. I think i've done some pretty complex and advanced programs in PBP and now I feel kind of bad with this ultra-noob question.

    PBP was my first experience with MCUs(I had programmed my fair share of things, but all in C, or basic on a PC), consequently I was not... enamoured so to speak with PBP. This semester I took a class on MCU's and programmed the entire class in assembly, and did my class final project in C.(We used freescale... eww.) Consequently... I'm back to PBP and PICs and I have a much higher impression of how truly useful and easy it is but this just baffles me. Its so simple... am I missing something obvious?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    What happens if you were to put a Pause 1 between the Red and Blue?

    main:
    red=0
    pause 1
    blue=1
    pause 500

    red=1
    pause 1
    blue=0
    pause 500

    goto main

  3. #3
    Join Date
    May 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    I copy and pasted your suggestion and it flashed Blue On, Blue off(red off), Blue On, Blue Off(red off)... and so forth.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    OK Melanie... always look at the Datasheet... turn the Comparator OFF... Put this in before your loop...

    CMCON=7

  5. #5
    Join Date
    May 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Well that was it... Now I'm off to find where I missed it in the datasheet... RTFM failure.

    Ninja:

    Unprecedented failure... the giant gray box that says NOTE:

    Sometimes I feel like a numbnuts.

    Thanks Melanie!
    Last edited by Perrin`; - 2nd January 2009 at 20:55.

Similar Threads

  1. Eeprom question
    By karenhornby in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th April 2008, 20:21
  2. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  3. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49
  4. Interrupt Newb Question:
    By Tear in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th June 2005, 19:04
  5. simple newb question
    By PICMAN in forum General
    Replies: 13
    Last Post: - 5th February 2005, 02:16

Members who have read this thread : 1

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