Hello,

I'm trying to send the content of a variable to a SPI LCD.

As long as I send "text", it works; the LCD shows "text".

When I try to send the content of a variable, i.e. a counter, the display goes crazy and shows sort of random characters.

Any idea what I'm doing wrong or missing?


Code:
' PIC 16F690 Fuses (MPASM)
   @ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF

' Registers   76543210
   OPTION_REG = %10000000 'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
   OSCCON     = %01110000 'Internal RC set to 8Mhz
   ANSEL      = %00000000 'Disable analog inputs Channels 0 to 7
   ANSELH     = %00000000 'Disable analog inputs Channels 8 to 11
   WPUB       = %00000000 'Disable weak pull-ups
   ADCON0     = %00000000 'A/D Module is OFF
   CM1CON0    = %00000000 'Comparator1 Module is OFF
   CM2CON0    = %00000000 'Comparator2 Module is OFF
   INTCON     = %00000000 'INTerrupts CONtrol
   TRISA      = %00000000 'Set Input/Output (0 to 5)
   PORTA      = %00000000 'Ports High/Low (0 to 5)
   TRISB      = %00000000 'Set Input/Output (4 to 7)
   PORTB      = %00000000 'Ports High/Low (4 to 7)
   TRISC      = %00000000 'Set Input/Output (0 to 7)
   PORTC      = %00000000 'Ports High/Low (0 to 7)
                                
'-------------------------------------------------------------------------------
' Defines
   define OSC 8

'-------------------------------------------------------------------------------
' Variables
   RS    var PORTB.5 'instruction or command =0, data =1
   SCK   var PORTB.6 'Clock pin
   SDO   var PORTB.4 'Data Out pin (SI on display's side)
         
   Reset var PORTB.7 'LCD's reset pin - could be connected to VDD (+VDC)
   CSB   var PORTC.7 'LOW active pin - could be connected to VSS (GND)

   Mode  con 1       'MSBFIRST - Clock idles low
   RS_t  con 1       'Set PAUSE time for RS transition

   Cnt_A var byte    'just a counter variable
   cnt_a = 0

'-------------------------------------------------------------------------------
INIT:
'  "EA-DOGM162L-A" LCD display specific settings
   pause 40     'wait for LCD to startup
   high reset  : pause 1
   low RS      : pauseus RS_t
   shiftout sdo,SCK,mode,[%00111001] : pauseus 20 'Function Set/Instr. table 1
   shiftout sdo,SCK,mode,[%00011100] : pauseus 20 'Bias set
   shiftout sdo,SCK,mode,[%01010010] : pauseus 20 'Power control + Contrast (HiByte)
   shiftout sdo,SCK,mode,[%01101001] : pauseus 20 'Follower control
   shiftout sdo,SCK,mode,[%01110111] : pauseus 20 'Contrast (LowByte)
   shiftout sdo,SCK,mode,[%00001100] : pauseus 20 'Display ON

'-------------------------------------------------------------------------------
MAIN:
  low rs : pauseus RS_t             'set COMMAND mode
  shiftout sdo,SCK,mode,[%00000010] : pause 1   'set cursor home

  high RS : pauseus RS_t            'set DATA mode
  shiftout sdo,SCK,mode,["test"]

  pause 500

  low rs : pauseus RS_t             'set COMMAND mode
  shiftout sdo,SCK,mode,[%00000010] : pause 1   'set cursor home

  high RS : pauseus RS_t            'set DATA mode
  shiftout sdo,SCK,mode,[Cnt_A]

  pause 500

  cnt_a = cnt_a + 1
  goto main:
Thank you

Roger

NB: most of the time, the "%" in my posts are replaced by some "double-square" symbol; how to I avoid this?