Strange Behaviour with Conditional Compile


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Strange Behaviour with Conditional Compile

    Hi,
    You have a lot of PAUSE statements within the LCD sections, most noticable is the PAUSE 1500 (1.5 seconds!) in the Map_VrefInVal_to_PWM_Duty subroutine which you call each time thru your Main routine. When you don't include the LCD sections in the code it runs MUCH faster compared to when you DO include the LCD sections.

    /Henrik.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Strange Behaviour with Conditional Compile

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    You have a lot of PAUSE statements within the LCD sections, most noticable is the PAUSE 1500 (1.5 seconds!) in the Map_VrefInVal_to_PWM_Duty subroutine which you call each time thru your Main routine. When you don't include the LCD sections in the code it runs MUCH faster compared to when you DO include the LCD sections.

    /Henrik.
    Thanks Henrik. That would definitely seem to explain the slow reaction to reading ADC during the main loop, but why would the duty cycle on the PWM output go HIGH as soon as power is turned on?

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Strange Behaviour with Conditional Compile

    Hi

    You might want to make sure that the dutycycle is set to 0 before enabling the PWM module.
    As it is now, when you "activate" the LCD sections, there will be a 7 second delay between the PWM module being enabled (you setting CCP4CON at the start of the program) and the time at which the ramp up actually starts, ie when you actually set the dutycycle to 0.

    /Henrik.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Strange Behaviour with Conditional Compile

    Thanks again, Henrik. Do you mean I should have:

    Code:
        CCP4CON.4 = 0
        CCP4CON.5 = 0
        CCPR4L    = 0
    before the CCP4CON register setting?

    I will try that out tonight, as well as reducing the PAUSE statements.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Strange Behaviour with Conditional Compile

    As usual, you were right Henrik. I added the code above right after turning on CCP/PWM on CCP4 and reduced all the pauses within the #IFDEF USE_LCD_FOR_DEBUG and now everything works as before. It was obvious once you pointed it out, so thanks again for being so patient.

Similar Threads

  1. Conditional compile
    By pedja089 in forum PBP3
    Replies: 2
    Last Post: - 16th January 2014, 22:25
  2. Strange IT behaviour
    By MikeBZH in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th February 2012, 10:00
  3. Strange behaviour
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th October 2009, 23:35
  4. Strange HSEROUT behaviour
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th July 2006, 00:37
  5. strange int behaviour
    By tom in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th November 2005, 16:41

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