Code Problems with 16F684


Closed Thread
Results 1 to 6 of 6

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Ryan7777, I can't help but notice that you are missing a compare value in the last statement:
    IF aTOd < 45 AND aTOd ??????? THEN DutyCycle1 = 1023
    ENDIF

    I think I would write this routine it as follows to save you some cycles:

    SELECT CASE aTOd
    CASE < 94
    DutyCycle1 = 10
    CASE < 187
    DutyCycle1 = 10
    CASE < 280
    DutyCycle1 = 30
    CASE < 373
    DutyCycle1 = 50
    CASE < 466
    DutyCycle1 = 70
    CASE < 559
    DutyCycle1 = 90
    CASE < 652
    DutyCycle1 = 110
    CASE < 745
    DutyCycle1 = 130
    CASE < 838
    DutyCycle1 = 150
    CASE < 931
    DutyCycle1 = 170
    CASE <= 1023
    DutyCycle1 = 200
    END SELECT

    That should save you some cpu cycles...

    Dave Purola,
    N8NTA

  2. #2
    Join Date
    Sep 2006
    Location
    Indiana, USA
    Posts
    72


    Did you find this post helpful? Yes | No

    Default Awesome!

    Thanks for your replies. I had always assumed that the 16F68Xs just defaulted to 8 instead of 4 Mhz. I'll OSCTUNE it to 8, as you said, it seems like everything is timing out to be twice as long. That explains a lot, Thanks! And yeah, I'll re-write it for select case for the end version, I was still hashing it out and ended up with rough code trying to figure out the timing issue. Now that I have that figured out, and If i can use serout to debug my dimming feature, I can tighten it all up.

    Thanks again to the both of you, You guys are awesome.

    Ryan

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


    Did you find this post helpful? Yes | No

    Default

    i'll osctune it to 8
    nope!!!
    Code:
    DEFINE OSC 8              
    OSCCON = %01110000
    Dave
    Always wear safety glasses while programming.

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