How can I speed this code up? SHIFTOUT is slowing it down and I need a faster way.


Closed Thread
Results 1 to 30 of 30

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    I think this is what Mike was talking about?

    This will give you 2.5MHz with every 16th logic 1 bit stretched to 4 cycles VS 1. If you can live with this bit being a tad longer, it will definitely speed things up.
    Code:
     
    ' define port & pin use in _Pulse
    @ #DEFINE PORT PORTB ' use any port you prefer, but declare it here
    @ #DEFINE PIN 6      ' same as above
     
    PORTB.6 = 1       ' initialize pin to idle state
    TRISB.6 = 0       ' make the pin an output
     
    C1 VAR BYTE BANK0 SYSTEM
     
    Main:
        C1 = 0        ' clear loop count
        CALL Pulse    ' generate 4096 pulses
        GOTO Main
     
    ASM
    _Pulse
        BCF PORT,PIN     ; clear pin / 1
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 2
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 3
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 4
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 5
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 6
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 7
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 8
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 9
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 10
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 11
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 12
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 13
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 14
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 15
        BSF PORT,PIN     ; set pin
        BCF PORT,PIN     ; clear pin / 16
        BSF PORT,PIN     ; set pin
        DECFSZ C1,F      ; decrement count, skip if 0
        GOTO _Pulse      ; not done, keep going
        RETURN
    ENDASM
    With either version, make sure you have WDT disabled.
    Attached Images Attached Images  
    Regards,

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

  2. #2
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41


    Did you find this post helpful? Yes | No

    Thumbs up Thanks Bruce that last bit of Code worked like a charm!!!

    I didn't have to turn off the WDT, I think its off by default but could not find where it tells me in the manual. What will happen if its on? Would I notice it?

    I do have one issue but it might just be an issue with it being on a bread board but when I use the Define OSC 20 with the 20 MHz clock it freaks out and does what ever it feels like and is sensitive to the touch but when I use no Define or Define OSC 4MHz but run it with the 20MHz clock it runs fine...I don't get it haha


    Thanks again everyone, I am very grateful for all your help and suggestions

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