Can anyone see a problem with this?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171

    Default Can anyone see a problem with this?

    I'm trying to build a synchronous motor control using a 12f629 but having problems even getting it going here's a simple code i wrote that wont work - any clues?

    @ device pic12F629, INTRC_OSC_NOCLKOUT, WDT_ON, MCLR_OFF, PROTECT_OFF, BOD_ON

    Define OSCCAL_1K 1
    DEFINE OSC 4

    CMCON = 7 'TURN COMPARITORS OFF
    TRISIO = %000000 ' Set GPIO 0,1 TO INPUT, others to OUTPUT

    Delay var word
    MaxSpeed var word

    Start:
    toggle gpio.5
    pause 100
    goto start

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Its probably not what's causing your problem, but to do what your comment says, the TRISIO line needs to be:

    TRISIO = %00000011

    What do you see when you hook up an LED to the output of GP5?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    First off, the TRIS is not right, but for GPIO.5, it is ok.

    When you toggle a pin, you have to consider the Read-Modify-Write issue. A better way to check would be to set the pin HIGH, wait for a delay time, set the pin low, delay and loop

    main
    high gpio.5
    pause 500
    low gpio.5
    pause 500
    goto main

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


    Did you find this post helpful? Yes | No

    Default

    Can anyone see a problem with this?
    Code wise, no. It should work as expected.

    If you have a read-modify-write problem with a 100mS delay between toggling an output,
    then you have a hardware issue with a boat-load of external capacitance on this pin.

    Remove the DEFINE OSCCAL_1K 1. If it works, then your device programmer has most likely
    erased the last program memory location of this PIC that had the RETLW xx, where xx was
    the factory OSCCAL calibration value being returned in the W register.

    DEFINE OSCCAL_1K 1 causes PBP to issue a CALL to location 0x3FF. Once at location 0x3FF
    it should RETURN with the factory OSCCAL value in W, which gets loaded into the OSCCAL
    register.

    If this has been erased, the CALL causes a nasty loop from 0x3FF right back to 0x00, since
    the RETLW instruction + the xx it should return has been erased.

    This causes your program to loop continuously from 0x3FF back to 0, making it appear that
    nothing is working.
    Regards,

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

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  4. Hardware problem or what ?
    By Steve S. in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 4th March 2007, 21:39
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

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