undocumented code


Closed Thread
Results 1 to 7 of 7

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    You don't mention which PIC you're using, but assuming it doesn't have some peripheral functions on portC, you're using limiting resistors on the LED's, and have them connected properly, your code should work fine.

    You may want to change the myArray.0[i-1] = 0 however.

    On the 1st pass, 0-1 = 255 which probably isn't doing what you may expect.
    On the last pass, 7-1 = 6, and you'll never clear RC7.

    Try something like this;
    Code:
    main:
        for i = 0 to 7
          myArray.0[i]= 1
          pause 50 ' or whatever
          myArray.0[i]= 0
        next
        goto main
    If I run the above example on a 16F876A, it turns on/off 8 LED's on portb in ~50mS intervals. I don't have a board with 8 LED's available on portc, but it should work all the same on any available 8-bit port. Assuming this port on the PIC you're using doesn't have some peripheral functions you have enabled.
    Regards,

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

  2. #2
    ilteris's Avatar
    ilteris Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the response Bruce. I am using 18f452 and what if I try to change your code like this below:

    Code:
    main:
        for i = 0 to 7
          myArray.0[i]= 1
        next
        goto main
    does this mean they are all going to be high and stay at that position? I have been trying to do this for 2 days now wit no dice.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 18:23

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