• AVR Freaks

Hot!Copying .PDF Code Into MPLAB X

Author
The Loner
Super Member
  • Total Posts : 570
  • Reward points : 0
  • Joined: 2016/12/18 10:59:17
  • Location: 0
  • Status: offline
2018/11/09 15:46:03 (permalink)
1 (4)

Copying .PDF Code Into MPLAB X

TMR0 EQU 1 ;TMR0 is FILE 1.
TRISIO EQU 85H
GPIO EQU 5 ;GPIO is FILE 6.
STATUS EQU 3 ;STATUS is FILE 3.

 
TMR0 EQU 1 ;TMR0 is FILE 1.
TRISIO EQU 85H
GPIO EQU 5 ;GPIO is FILE 6.
STATUS EQU 3 ;STATUS is FILE 3.
post edited by Total Amateur - 2019/01/01 10:15:30

Everything on the net.
Everything you see.
0's and 1's.
 
 
 
 
 
 
 

 
 
 
 
 
#1

9 Replies Related Threads

    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2018/11/09 15:52:59 (permalink)
    1 (4)
     
    Anybody know how to copy code from .PDF programming book int MPLAB X?
     
    Adobe has offer to sign up for Adobe Acrobat Pro.
     
    Will that work? Converting .pdf to Word documents and THEN pasting them into MPLAB X?

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #2
    PStechPaul
    Super Member
    • Total Posts : 2394
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2018/11/10 01:00:13 (permalink)
    0
    I copied this code from the Microchip PDF data sheet for the PIC16F1788-9. You can past it into MPLABX or any text editor:
    ;This code block configures the ADC
    ;for polling, Vdd and Vss references, Frc
    ;clock and AN0 input.
    ;
    ;Conversion start & polling for completion
    ; are included.
    ;
    BANKSEL ADCON1 ;
    MOVLW B’11110000’ ;2’s complement, Frc
    ;clock
    MOVWF ADCON1 ;Vdd and Vss Vref
    MOVLW B’00001111’ ;set negative input
    MOVWF ADCON2 ;to negative
    ;reference
    BANKSEL TRISA ;
    BSF TRISA,0 ;Set RA0 to input
    BANKSEL ANSEL ;
    BSF ANSEL,0 ;Set RA0 to analog
    BANKSEL ADCON0 ;
    MOVLW B’00000001’ ;Select channel AN0
    MOVWF ADCON0 ;Turn ADC On
    CALL SampleTime ;Acquisiton delay
    BSF ADCON0,ADGO ;Start conversion
    BTFSC ADCON0,ADGO ;Is conversion done?
    GOTO $-1 ;No, test again
    BANKSEL ADRESH ;
    MOVF ADRESH,W ;Read upper 2 bits
    MOVWF RESULTHI ;store in GPR space


     
    #3
    crosland
    Super Member
    • Total Posts : 1613
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2018/11/10 05:18:32 (permalink)
    0
    On Windows, highlight the text, right-click, copy, but, are you sure the book is not copy protected?
    #4
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2018/11/10 06:42:13 (permalink)
    1 (4)
     
    Paul
     
    Thanks but that is same result I am getting.
     
    Pasted in code is all bunched up.
     
    Crosland
     
    Same thing doing it that way. Ends up bunched up.
     
    I see you are in the UK. Let me know if you would look for the author for me.
     
    Maybe you can search better better there.
     
    I doubt the book is copyrighted.
     
    .PDF to Word conversion looks like it is a pretty known situation. Lots of converters including Abobe's.
    post edited by Bucky - 2018/11/10 06:43:59

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #5
    rodims
    Super Member
    • Total Posts : 1519
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2018/11/10 07:48:18 (permalink)
    0
    For me its not clear which PDF book you are referring to. 
    And what does "all bunched up" mean ?
     
    Pauls copy/paste from the Microchip PDF (Example 17-1) is correct, the only thing is that spaces/blanks are missing, which destroys the column alignment. However testing with exactly Pauls PDF document and example code I tested the following (I'm using Firefox Browser and Foxit PDF Reader).
    And I verified that the source of the problem is the "copy" not the "paste" (Nirsoft Inside Clipboard).
     
    Results:
    a) Loading the PDF in Foxit from disk shows a result like Paul posted.  N blanks are reduced to 1 blank.
    b) Googling the same PDF and open it in Firefox keeps the blanks and thus formatting.
    So the workaround here is to load the PDF with Firefox, not with Foxit.  This kept formatting.
     
    However the PDF rendering in Firefox is still done by some Foxit component, which is by default (but optionally) installed during Foxit setup. 
     
    Apparently you are using Acrobat Reader, so probably you have an Adobe Browser component for PDF rendering.
    I cannot test that for you.  But like with Foxit you should at least test, whether it makes a difference when loading the PDF with Foxit.
    (I also tested Chrome, which likely has its own PDF engine, -> it also "eats" the blanks. )
     
    It's not really clear, whether that is you problem, but if yes, the above combination could be a solution, otherwise simply test more  PDF readers and check what they copy to the clipboard. 
     
    post edited by rodims - 2018/11/10 07:49:46
    #6
    PStechPaul
    Super Member
    • Total Posts : 2394
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2018/11/10 11:57:41 (permalink)
    4 (1)
    I copied the text from Adobe Reader, not with a browser. And it's easy enough to add whatever formatting you want to the copied code. Also, you should be writing your own code, except maybe for small snippets like the ADC code I posted.
     
    Do you have anything working yet?

     
    #7
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2018/11/10 21:53:02 (permalink)
    1 (4)
     
    Thank you for all the suggestions.
     
    Just going to sign up for free trial Adobe Reader Pro and then convert the .PDF to Word.
     
     
     
     
     
     

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #8
    The Loner
    Super Member
    • Total Posts : 570
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2019/01/01 09:57:07 (permalink)
    1 (1)
     
    Never did figure out how to fix this.
     
    This is where it stands.
     
    Copy code from .PDF book.
     
    Paste into MPLABX.
     
    It looses formatting. Each line is still on it's own line but no more being in columns.
     
    So I right arrow and tab to put it back right.
     
    It's only from 'Program starts here' to END. So it is not a lot of editing really.
     
    I use a header each time and paste in any delay subroutines from a delay file I made.
     
    It's manageable.
     
    Thanks for the suggestions.

    Everything on the net.
    Everything you see.
    0's and 1's.
     
     
     
     
     
     
     

     
     
     
     
     
    #9
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3289
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Test- Copying .PDF Code Into Code Window 2019/03/06 09:25:02 (permalink)
    0
    Bucky.

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5