From c to pbp


Closed Thread
Results 1 to 13 of 13

Thread: From c to pbp

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I have made the pcb and these days i will try if work.
    Thank you Bruce
    I test and work , but it should not all the delays they is same; PAUSE9

    Edit: I use the code as you post , without any change.
    Last edited by savnik; - 28th July 2007 at 09:46.

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    971


    Did you find this post helpful? Yes | No

    Default

    The delays shown by Bruce are mistakenly wrong. The original code shows delay_cycles(59) That is delay for 59 cycles. So, by using Bruce's code as a start, you can make the delay for 59 cycles. This will give you the correct timings. Another thing, the oscillator is 20MHz. So, the initial define has to be
    Code:
    define OSC  20000000
    
    cntr    byte    1
    
    delay_cycles59:             ' 2 cycles to get here
    
    asm
             MOVLW  11          ' 1 cycle
             MOVWF  _cntr      ' 1 cycle
    loop:  DECFSZ _cntr,F     ' 1 cycles  (3*17+1 = 52)
             GOTO   loop          ' 2 cycles
             nop                    ' 1 cycle
             return                 ' 2 cycles
    
    endasm
    The above has a subroutine to give you an exact delay of 59 cycles. You can call the function from PBP like this
    Code:
             gosub  delay_cycles59
    Last edited by Jerson; - 28th July 2007 at 16:24. Reason: Added code

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


    Did you find this post helpful? Yes | No

    Default

    Per Savniks' original post,
    How to change this code to picbasic pro.Also i want to use xtal 4MHZ
    I think he's looking for a similar function, but with a 4MHz osc VS 20MHz.

    If not, then of course the timing in my example would indeed be wrong.
    Regards,

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

  4. #4
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Per Savniks' original post,
    I think he's looking for a similar function, but with a 4MHz osc VS 20MHz.

    If not, then of course the timing in my example would indeed be wrong.
    Yes , I was looking for a similar function, but with a 4MHz Xtal.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 13:55
  2. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 14:43
  3. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 20:01
  4. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2005, 00:30
  5. PBP / XP Crash
    By pondindustrial in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th November 2005, 04:16

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