Announcement

Collapse
No announcement yet.

PBP3 Example Program - LOOKUP.pbp

Collapse
X
Collapse

  • 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
      Posting comments is disabled.

    Article Tags

    Collapse

    Latest Articles

    Collapse

    • USART.pbp
      John Tighe
      PICBASIC PRO program to demonstrate reading & writing the hardware serial port without HSERIN/HSEROUT. Defaults to 2400 bps. ' Name : USART.pbp ' Compiler : PICBASIC PRO Compiler 2.6 ' Assembler : PM or MPASM ' Target PIC : 16F, 18F with hardware USART ' Hardware : PC hardware serial port connection ' Oscillator : 4MHz external crystal or resonator ' Keywords : HARDWARE USART ' Description : PICBASIC PRO program to demonstrate reading & writing ' the hardware serial port without HSE...
      10-24-2011, 02:05 PM
    • SPISLAVE.pbp - Slave SPI using hardware (M)SSP module
      John Tighe
      PicBasic Pro program SPI slave program (see spimast.pbp for connections) Common ground is required....
      10-24-2011, 02:04 PM
    • SPIMAST.pbp - Master SPI using hardware (M)SSP module
      John Tighe
      PicBasic Pro program to read and write to SPI slave using the hardware synchronous serial port. Connect SDI(master) to SDO(slave), SDO(master) to SDI(slave), AND SCK(master) to SCK(slave). Common ground is required. Sends ascii "?" to request data, waits for a "!" to begin receiving data. Expects to find the ADC conversion value in the 6th position of the received string. ' Name : SPIMAST.pbp ' Compiler : PICBASIC PRO Compiler 2.6 ' Assembler : PM or MPASM ' Target PIC : 40-pin 16F or 18...
      10-24-2011, 02:02 PM
    • SOUND.pbp
      John Tighe
      PICBASIC PRO Code to demonstrate the SOUND command. Makes random computer-like noises. More refinement might make sound effects realistic enough to convince your boss youre working when youre really just playing Doom!!! ' Name : SOUND.pbp ' Compiler : PICBASIC PRO Compiler 2.6 ' Assembler : PM or MPASM ' Target PIC : 12F, 16F, 18F ' Hardware : 8-ohm speaker, 10uF electrolytic or tantalum cap ' Oscillator : 4MHz internal or external ' Keywords : RANDOM, SOUND ' Description : PICBAS...
      10-24-2011, 02:01 PM
    • SLEEP.pbp
      John Tighe
      PICBASIC PRO Code to demonstrate the SLEEP command. Slowly blinks an LED using low power mode delay....
      10-24-2011, 01:59 PM
    • SHIFT.pbp
      John Tighe
      PICBASIC PRO Code to demonstrate the use of SHIFTIN / SHIFTOUT commands....
      10-24-2011, 01:57 PM
    Working...
    X