New to programming and am having a few issues with some code


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: New to programming and am having a few issues with some code

    well... maybe not a bad idea to read the ADC again once in a while, as it is right now you read it only once
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: New to programming and am having a few issues with some code

    About your POWER LED not coming on:

    How about taking a copy of that last code, deleting all the lines except the absolute minimum to get the power LED on.

    Just keep the config, variable, ports, etc. Get rid of everything else, it's cluttering your view.

    I bet you have a config set up wrong, or your wiring is not exactly as you think it is.

    Robert


    Dumb question #1: Did you try to light the POWER LED and resistor directly to confirm it does indeed work?

    #2: Maybe you blew the pin on the PIC, try another one.

    #3: PWMOUT VAR GPIO.0 <-- Is this your POWER LED? You never turn it on, you only define it (or maybe I'm missing something).

    #4: TRISIO = %00000111 <-- port 0 is set as input, it should be TRISIO = %00000110.
    Last edited by Demon; - 24th April 2012 at 03:56. Reason: Cause I keep going back to the code and getting more ideas.

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: New to programming and am having a few issues with some code

    I also notice that you are not setting the CMCON0 register. If not then it is defaulting to GP0 and GP1 as analog inputs and GP2 as digital. If you are not using the comparator then you should be setting it to %00000111. This will allow port GP0 to be digital. It's all in the data sheet.....
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    Apr 2012
    Location
    Leicester UK
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: New to programming and am having a few issues with some code

    I tried the resistor and the LED separately, with your help and looking through the datasheet again it does seem that it is the configuration settings.

    Demon
    #3: PWMOUT VAR GPIO.0 <-- Is this your POWER LED? You never turn it on, you only define it (or maybe I'm missing something)
    - I was initally going to use these labels instead of the binary code for the pins, but I ended up using the binary numbers as I wanted to be able to turn more than one pin on and off at a time. Though the pin names are left in incase I wish to use them in the future.

    Dave
    I never realised that I needed to set the CMCON0 register as I decided to not look into the comparator section of the datasheet as this is not a function I am using at this time. I'll spend more time reading the rest of the datasheet now to see if there is any other bits I have missed.

    I shall look at the registers later tonight to see if there is anything else I have missed.

    Many thanks for your help.

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


    Did you find this post helpful? Yes | No

    Default Re: New to programming and am having a few issues with some code

    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: New to programming and am having a few issues with some code

    Actually Robert, He is comanding the power led to light every time he is sending the commands to the other led's with any of the GPIO statements like: GPIO = %00010001
    Dave Purola,
    N8NTA
    EN82fn

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: New to programming and am having a few issues with some code

    Ah, thanks Dave, now I see it as plain as the nose on my face.

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