• LOOKUP.pbp

    PICBASIC PRO program to demonstrate LOOKUP & RANDOM commands. Converts numeric value to ASCII hexadecimal equivalents.
    ' Name        : LOOKUP.pbp
    ' Compiler    : PICBASIC PRO Compiler 2.6
    ' Assembler   : PM or MPASM
    ' Target PIC  : 12F, 16F or 18F
    ' Hardware    : PC serial connection & terminal for result display
    ' Oscillator  : 4MHz internal or external
    ' Keywords    : LOOKUP, RANDOM, SEROUT
    ' Description : PICBASIC PRO program to demonstrate  LOOKUP & RANDOM commands.
    ' Converts numeric value to ASCII hexadecimal equivalents.
    '
    
    Include "bs1defs.bas"  ' Include BS1 variable and serial definitions
    
    SO Con 0               ' Define serial out
    
    mainloop:
       W6 = W0 : Gosub HexW    ' Print W0
       Serout SO,N2400,[13,10] ' Print end of line
       Random W0		   ' Randomize W0
       Goto mainloop           ' Do this forever!!!
    
       ' Send W6 as XXXX (Uses W5)
    
    HexW:
       Gosub HexB13            ' Print MSB
       B13 = B12               ' Print LSB
    
    HexB13:
       B11 = B13 / 16          ' Print MSB
       Gosub HexB11
       B11 = B13 & 15
    
    HexB11:
       Lookup B11,["0123456789ABCDEF"],B10 ' B10 = HEX$(B11)
       Serout SO,N2400,[B10]
       Return
    
       End
    
               
    Download the file lookup.pbp
  • Recent Forum Posts

    richard

    One Wire Transmission

    ooops ! typo


    Code:
    define OSC 8
    tdata    var byte[4]
    dbit     var byte
    tobj     var word  ;  top 16 bits of reading

    richard 1 Hour Ago Go to last post
    Keith55555

    One Wire Transmission

    Thanks Richard. I'll play with that. I'm only in need of the least significant 8 bits. They have an I2C version which I'm more comfortable with but Digi-Key

    Keith55555 9 Hours Ago Go to last post
    richard

    One Wire Transmission

    something like this may work

    Code:
    define OSC 8
    tdata    var byte[4]
    dbit     var byte
    tobj     var word  ;  top

    richard 9 Hours Ago Go to last post
    richard

    One Wire Transmission

    this is the reccomended routine from the data sheet

    [QUOTE]for(i=0;i

    richard 10 Hours Ago Go to last post
    Keith55555

    One Wire Transmission

    Can someone advise me on this serial protocol and how to structure reading/assembling it?
    I understand the read command, I don't understand how

    Keith55555 12 Hours Ago Go to last post