Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic Confusion? — Parallax Forums

PropBasic Confusion?

FriedVFriedV Posts: 77
edited 2011-09-28 12:00 in Propeller 1
Hi,
I try to attach a MDOG LCD to a C3 Board.
I wrote the following init code:
' ----------------------------------------------------------------------
' File......  C3_SPI.pbas
' Author....  fgvissel  28.09.2011
' for C3 Board with 6,26 MHz X-tal
' ======================================================================

' ----- Device Settings ------------------------------------------------
  DEVICE P8X32A, XTAL1, PLL16X
  XIN 6_250_000

' ----- Conditional Compilation Symbols --------------------------------
 
' ----- Constants ------------------------------------------------------

' ----- IO Pins --------------------------------------------------------
  PSI_CLR Pin 25 High
  PSI_CLK Pin  8 High

  RS      Pin 10 Output
  MOSI    Pin  9 Output
  MCLK    Pin 11 Output

' ----- Shared (HUB) Variables (Byte, Word, Long) ----------------------

' ----- User Data (DATA, WDATA, LDATA, FILE) ---------------------------

' ----- TASK Definitions -----------------------------------------------

' ----- Local Variables (LONG only) ------------------------------------
  channel var long
' ----- SUB and FUNC Definitions ---------------------------------------
  DelayMS SUB 1
  DelayUS SUB 1

' ======================================================================

PROGRAM Start

Start:
low PSI_CLR         'reset CS Counter in C3
high PSI_CLR 


channel = 0         'select S6 device
do  
  low PSI_CLK
  high PSI_CLK
  inc channel
loop until channel = 6


low RS

'Init LCD

  delayMS 40
  shiftout MOSI, MCLK, MSBFIRST,$39 
  delayUS 27
  shiftout MOSI, MCLK, MSBFIRST,$14 
  delayUS 27
  shiftout MOSI, MCLK, MSBFIRST,$55
  delayUS 27
  shiftout MOSI, MCLK, MSBFIRST,$6D
  delayUS 27
  shiftout MOSI, MCLK, MSBFIRST,$78
  delayUS 27
  shiftout MOSI, MCLK, MSBFIRST,$38
  delayUS 27
  shiftout MOSI, MCLK, MSBFIRST,$0F
  delayUS 27
  shiftout MOSI, MCLK, MSBFIRST,$06
  delayUS 27
   shiftout MOSI, MCLK, MSBFIRST,$41
 delayUS 32
high RS


Main:
' program code
GOTO Main
END

' ----- SUB and FUNC Code ----------------------------------------------
  SUB delayMS
  pause __param1
  ENDSUB

  SUB delayUS
  pauseus __param1
  ENDSUB

  
' ----- TASK Code ------------------------------------------------------



' ----------------------------------------------------------------------
This compiles ok, loading with bstc to the c3 yields:
---------- Download to RAM ----------
Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved
Compiled for i386 Win32 at 08:17:48 on 2009/07/20
Loading Object C3_SPI
Program size is 920 longs
Compiled 273 Lines of Code in 0,016 Seconds
We found a Propeller Version 1
Propeller Load took 0,654 Seconds

Output completed (0 sec consumed) - Normal Termination
Program runs ok, see LA01 output (BTW The DOG LCD does not init correctly??)
la01.jpg

Why? 920 longs -> too much for cog memory?
273 lines of code? no, spin file has 391 lines?
BTW what does the speed param mean in shiftout? MCLK time?
Friedrich
1024 x 640 - 68K

Comments

  • BeanBean Posts: 8,129
    edited 2011-09-28 12:00
    Put the SHIFTOUT command in a subroutine so it only gets generated once instead of each time.

    The speed param is the clock speed multiplier.

    Bean
Sign In or Register to comment.