1 / 17

# Example 13 The Serial Peripheral Interface (SPI) - PowerPoint PPT Presentation

Example 13 The Serial Peripheral Interface (SPI). Lecture L9.1. PIM_9DP256 Block Diagram. 3 SPI Ports. SPI2 Pins PP4 – PP7. Pins 112,111,110,109. SPI1 Pins PP0 – PP3. Pins 4,3,2,1. SPI0 Pins PS4 – PS7. Pins 93,94,95,96. SPI2 Pins PP4 – PP7. Pins 112,111,110,109. SPI1 Pins

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

## PowerPoint Slideshow about 'Example 13 The Serial Peripheral Interface (SPI)' - locke

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

### Example 13 The Serial Peripheral Interface (SPI)

Lecture L9.1

Block Diagram

3 SPI Ports

PP4 – PP7

Pins 112,111,110,109

SPI1 Pins

PP0 – PP3

Pins 4,3,2,1

SPI0 Pins

PS4 – PS7

Pins 93,94,95,96

PP4 – PP7

Pins 112,111,110,109

SPI1 Pins

PP0 – PP3

Pins 4,3,2,1

SPI0 Pins

PS4 – PS7

Pins 93,94,95,96

int data;

char c;

SS0_LO(); // latch data

SS0_HI();

c = send_SPI0(0); // get 1st byte by sending dummy data

data = c;

data = data << 8;

c = send_SPI0(0); // get 2nd byte by sending dummy data

data = data | c;

return data;

}

const char keytbl[] = {

0x3, 0x2, 0x1, 0x0,

0x8, 0x9, 0xA, 0xB,

0x7, 0x6, 0x5, 0x4,

0xC, 0xD, 0xE, 0xF

};

int data;

int i;

char found;

char key;

found = 0;

i = 0;

while((i < 16) && (found == 0)){

found = 1;

key = keytbl[i];

}

else {

i++;

}

}

return key;

}

#include <hidef.h> /* common defines and macros */

#include <mc9s12dp256.h> /* derivative information */

#include "main_asm.h" /* interface to the assembly module */

char get_key(void);

void main(void) {

char key;

PLL_init(); // set system clock frequency to 24 MHz

lcd_init(); // enable lcd

SPI0_init(); // enable SPI0

while(1) {

key = get_key();

if(key < 16){

key = hex2asc(key); // convert to ascii

data8(key); // display on lcd

}

}

}