MS_uC / fue1 / V08 4- 1 SSP Programming Microcontroller SPP and File system 32K Byte Burst Flash 64K...
-
date post
22-Dec-2015 -
Category
Documents
-
view
228 -
download
2
Transcript of MS_uC / fue1 / V08 4- 1 SSP Programming Microcontroller SPP and File system 32K Byte Burst Flash 64K...
4- 1
SSP
MS_uC / fue1 / V08
Programming MicrocontrollerSPP and File system
32K Byte 32K Byte Burst FlashBurst Flash
64K or 96K 64K or 96K Byte SRAM Byte SRAM
256K or 512K 256K or 512K Byte Burst Byte Burst
FlashFlash
OTP OTP MemMem
UARTUARTI2CI2CSPISPITIMTIMRTCRTC
EXT. EXT. Bus Bus
GPIOGPIO
USB USB 2.0FS 2.0FS
CAN CAN 2.0B 2.0B
Enet Enet MAC MAC
PFPFQ Q
BC BC
DMADMA
INTINTR R
CntlCntl
ARM96ARM966E 6E CORE CORE
w/DSPw/DSP96 MHz 96 MHz
CLK CLK CntlCntl
ADCADC
LVD LVD BODBOD
PLLPLL JTAJTAGG
ETMETM99
4- 2
SSP
MS_uC / fue1 / V08
Synchronous Serial Peripheral (SSP)
SSP is serial high-speed bus system Display, AD- & DA converters
SSP is always used in a master-slave mode Master is responsible for the clock generation
SSP works in a duplex mode MOSI & MISO
EIA: Electronic Industry Alliance
4- 3
SSP
MS_uC / fue1 / V08
SSP Hardware flow control
Participant 1
7 0
Clock generator Data input parallel
Data output parallel
Participant n
7 0
Data input parallel
Date output parallel
4- 4
SSP
MS_uC / fue1 / V08
SSP features
Master & Slave modes Programmable choice of interface operation
Motorola SPI National Microwire TI synchronous serial
Programmable data frame size from 4 to 16 bits Programmable bit rate and Internal clock prescaler Separate transmit and receive FIFO buffers
16 bits wide and 8 locations deep Support for DMA Independent masking of transmit & receive FIFO
interrupts Internal loopback test mode Dynamic change from “Master Slave” or “Slave
Master”
4- 8
SSP
MS_uC / fue1 / V08
SSP Configuration (1/3)
SSP Control Register 0 (SSP_CR0) Frame Format bits (FRF)
Select one of the three protocols• Motorola SPI• Texas Instruments SSI• National Semiconductor Microwire
Data Size Select bits (DSS) Select the data word size
Serial Clock Rate bits (SCR) Fix the transmit and receive bit rates from the SPI Master
Clock
CPHA & CPOL bits Clock Phase and Polarity, applicable to Motorola SPI format
4- 9
SSP
MS_uC / fue1 / V08
SSP Configuration (2/3)
SSP Control Register 1 (SSP_CR1) Master or Slave (MS) selection bit
To configure the SSP as a master (MS = 0) or slave (MS = 1)
SSP Enable (SSE) To enable the SSP (SSE = 1)
SSP Presale Register (SSP_PR) Clock Presale Register bits
Fix the SPI Master Clock
4- 11
SSP
MS_uC / fue1 / V08
Pin connections of SSP
STR91x ARM966 manual 12274.pdf, 4.1 pin functions page 36
P5.4 UART0_SCLK Alternate Output 2P5.5 UART0_MOSI Alternate Output 2P5.6 UART0_MISO Alternate Input 1P5.7 GPIO_5.7 Alternate Output 1
Use the SD Card adapter of MCBSTR9. Which port?
4- 12
SSP
MS_uC / fue1 / V08
File system (FS)
FS is a method for storing & organizing computer files
FS use data storage devices Hard disk, CD-ROM, SD cards …
Array of fixed size blocks, called sectors (512, 1k, 2k or 4k bytes)
File system organize these sectors into files and directories
4- 13
SSP
MS_uC / fue1 / V08
Type of FS
Disk file system Storage of the files on disk drive
FAT, NTFS and HFS
Flash file system Storage of the files on flash memory devices
MMC or SD cards
Network file system Acts as a client for remote file access
NFS (Network File System) AFS (Andrew File System) SMB (Server Message Block)
4- 14
SSP
MS_uC / fue1 / V08
Secure Digital (SD) Memory Card
SD is a non volatile memory card Developed by Matsushita, ScanDisk and Toshiba
Use range of SD Cards Digital cameras Handheld computers PDAs mobile phones GPS receivers video game consoles
Capacities range from 4 MB to 2 GB
4- 15
SSP
MS_uC / fue1 / V08
Pin assignments
Pin no. Symbol Direction
Description
In Out
1 CS Chip select
2 DI Data in
3 VSS GND
4 VDD VCC
5 SCLK Clock
6 VSS2 GND
7 DO Data out
4- 16
SSP
MS_uC / fue1 / V08
Structure of FAT partition disc
Boot sector, BIOS Parameter Block with some basic information about the file
system Boot loader of the operating system
FAT Region This region contains two copies of the File Allocation Table
Root Directory Region. Information about the files and directories located in the root
directory
Data Region. This region contains the files and directories
Files are allocated entirely in a cluster If a 1 KB file resides in a 32 KB cluster, 31 KB are wasted
Bootsector
File Allocation Table 2
File Allocation Table 2
RootDirectory(FAT12/16 only)
Data Region (for files and directories)
4- 17
SSP
MS_uC / fue1 / V08
File Allocation Table (FAT)
A partition is divided up into identically sized clusters Cluster sizes vary between 2 KB and 32 KB.
Each file may occupy one or more of these clusters A File is represented by a chain of these clusters (singly
linked list)
FAT contains information about the clusters Each entry records one of five things
The cluster number of the next cluster in a chain A special end of cluster chain (EOC) A special entry to mark a bad cluster A special entry to mark a reserved cluster A zero to note that the cluster is unused
4- 18
SSP
MS_uC / fue1 / V08
File Allocation Table (example)
Number Value Meaning
Cluster 1 0000 Empty
Cluster 2 0003 Used
Cluster 3 0004 Used
Cluster 4 0006 Used
Cluster 5 0001 Reserved
Cluster 6 0007 Used
Cluster 7 FFFF EOF
4- 19
SSP
MS_uC / fue1 / V08
Directory table
A directory table is a special type of file that represents a directory Its files or directories are represented by a 32-byte entries
Name Extension Attributes (archive, hidden, read-only) Date & time of creation Address of the first cluster Size of the file/directory
4- 20
SSP
MS_uC / fue1 / V08
Application Interface (API) of a FS
The file are represented with FILE objects
The read & write functions need a pointer to the FILE objects fopen()
Furnishes a pointer to the given FILE object
Example #include <stdio.h>
FILE *FilePointer;
FilePointer = fopen ("c:\\Text.txt", "w");
if (FilePointer == NULL) {
printf ("Error, the file could not be opened !\n");
}
4- 21
SSP
MS_uC / fue1 / V08
FILE *fopen (char filename[], char mode[])
First argument of the fopen function File name
Second argument of the fopen function Access type
"r" Open the file for read"w" Create the file for write"a" Create or open the file for write at the end
of it"r+" Open the file for update (read and write)"w+" Create the file for update "a+" Create or open the file for update at the
end of it
4- 22
SSP
MS_uC / fue1 / V08
int fclose (FILE *stream)
When the file will not be used The link to the file must be close with fclose()
Example fclose (FilePointer);
4- 23
SSP
MS_uC / fue1 / V08
Function to read from or print into files
Key board/screen Function
File
printf("v = %d", i) Formatted output
fprintf(FilePointer, "v = %d", i)
scanf("%f", f) Formatted input
fscanf(FilePointer, "%f", f)
c = getchar() Read a character
c = fgetc(FilePointer)
putchar(c) Write a character
fputc(c, FilePointer)
gets(Buffer) Read a sentence
fgets(Buffer,Maxlength,FilePointer)
puts(Text) Write a sentence
fputs(Text, FilePointer)