the serial peripheral interface spi l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
The Serial Peripheral Interface (SPI) PowerPoint Presentation
Download Presentation
The Serial Peripheral Interface (SPI)

Loading in 2 Seconds...

play fullscreen
1 / 26

The Serial Peripheral Interface (SPI) - PowerPoint PPT Presentation


  • 131 Views
  • Uploaded on

The Serial Peripheral Interface (SPI). Chapter 8 CML9S12-DP256. PIM_9DP256 Block Diagram. Liquid Crystal Display. Relationship between RS, R/W, and E. CLM912-DP256 LCD PORT 4-bit SPI Interface Write only. File: SPI0.WHP. \ Serial Peripheral Interface SPI0 HEX

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'The Serial Peripheral Interface (SPI)' - nova


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide2

PIM_9DP256

Block Diagram

slide20

CLM912-DP256

LCD PORT

4-bit SPI

Interface

Write only

slide21

File: SPI0.WHP

\ Serial Peripheral Interface SPI0

HEX

00D8 CONSTANT SPI0CR1 \ SPI Control Register 1

00D9 CONSTANT SPI0CR2 \ SPI Control Register 1

00DA CONSTANT SPI0BR \ SPI Baud Rate Register

00DB CONSTANT SPI0SR \ SPI Status Register

00DD CONSTANT SP0DR \ SPI Data Register

: SPI.INIT ( -- ) \ Initialize SPI port

10 SPI0CR2 C! \ enable /SS

00 SPI0BR C! \ 4 MHz (/2)

52 SPI0CR1 C! ; \ CPHA = 0, CPO; = 0

: ?SPI.DONE ( -- f ) \ Is SPI data sent?

7 SPI0SR ?HI ;

: SEND.SPI ( c -- )

SP0DR C! \ send char

BEGIN

?SPI.DONE \ wait till sent

UNTIL

SP0DR C@ DROP ; \ clear SPIF

slide23

\ LCD for Axiom CML9S12-DP256

load hex2asc.whp

load string.whp

load spi0.whp

DECIMAL

: 10ms.delay ( -- )

7267 FOR NEXT ;

: 20ms.delay ( -- )

10ms.delay

10ms.delay ;

: 50ms.delay ( -- )

5 FOR 10ms.delay NEXT ;

slide24

HEX

\ Write 4-bit instruction

: >instr4 ( n -- )

0F AND

DUP send.spi \ EN LO, RS LO

DUP 80 OR \ EN HI

send.spi

send.spi ; \ EN LO

\ Write 8-bit instruction

: >instr8 ( n -- )

DUP 4 RSHIFT

>instr4

>instr4 ;

\ Write 4-bit data

: >data4 ( c -- )

0F AND

DUP 40 OR send.spi \ EN LO, RS HI

DUP C0 OR send.spi \ EN HI

40 OR send.spi ; \ EN LO

\ Write 8-bit data

: >data8 ( n -- )

DUP 4 RSHIFT

>data4

>data4 ;

slide25

\ Initialize 4-bit wide

: lcd.init ( -- )

50ms.delay

3 >instr4 \ function set

50ms.delay

3 >instr4 \ function set

50ms.delay

3 >instr4 \ function set

50ms.delay

2 >instr4 \ function set

50ms.delay

2C >instr8 \ 4-bits, 2 lines

10ms.delay

06 >instr8 \ inc cursor

10ms.delay

0f >instr8 \ display on

10ms.delay

01 >instr8 \ clear display

20ms.delay

80 >instr8 \ set addr to 0

10ms.delay

0 send.spi \ turn off all signals

0A BASE ! ; \ decimal default

slide26

: clear.lcd ( -- )

1 >instr8

10ms.delay ;

: hex>lcd ( hex -- )

HEX2ASC >data8 ;

: type.lcd ( addr len -- )

?DUP

IF

0 DO

DUP C@

>data8 10ms.delay 1+

LOOP

THEN

DROP ;

: .lcd ( n -- )

(.) type.lcd ;

: u.lcd ( u -- )

(u.) type.lcd ;

DECIMAL