Stuck on porting code to 18F4520


Closed Thread
Results 1 to 40 of 43

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Stuck on porting code to 18F4520

    Tried that and the steps are too much, almost rising in 5% increments - this is why I'm looking for an alternative. Shame PBP doesn't support FP and recognise 0.073s as a value

  2. #2
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Stuck on porting code to 18F4520

    The only issue is timing!

    You have set TMR0 at 1/2 second intervals

    Code:
    ClockLoop: IF intcon.2=0 THEN ClockLoop	'Poll for TMRO overflow
    INTCON.2=0 ' Clear TMRO overflow flag
    
    HzTimer=HzTimer-$1000	'decrement timer count
    
    IF HzTimer < $1000  THEN
    IF Col=10 THEN    ' update time'
    SS=SS+1
            
    IF SS=60 THEN   ' minute
    SS=0 
    MM=MM+1
    IF MM=60 THEN    ' hour            
    MM=0
    HH=HH+1
    IF HH=24 THEN HH=0
    ENDIF                           
    counter1 = (HH*60)+MM
    ENDIF
    ENDIF
    Col=Col+1
    
    HzTimer=HzTimer+$7A12	' Add 0.5 seconds to count
    ELSE
        ' Do something here but must be less than 65.5 mSec
    ENDIF
    And again this code works every second

    Code:
    case DAWN 
    lcdout $FE,$80+13,"DAWN "   
    if ss//1= 0 then
    if ss != old_ss then
    B_PWM=B_PWM+1
    old_ss=ss
    endif
    endif
    if B_PWM = b_max then
    Blue_Day_Cycle = DAY
    endif
    Change your TMR0 code +$7A12 to a lower value for say 1 msec. Then include for milliseconds in your clock and change all of the ss//1=0 instructions to trigger every 73 ms. I guess there will be more issues thrown up but looks easy to me.

Similar Threads

  1. Porting code to new PIC
    By malc-c in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 31st December 2010, 23:20
  2. Kind of stuck
    By gti_uk in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 31st May 2009, 20:45
  3. Getting Stuck in loop
    By Frozen001 in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 19th November 2008, 15:46
  4. Any idea's on porting this to PBP?
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th October 2008, 19:21
  5. Replies: 1
    Last Post: - 8th May 2008, 00:52

Members who have read this thread : 1

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