Download ppt - BFH-TI / Organisation

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
SSP
MS_uC / fue1 / V08
4- 1
Programming Microcontroller
SPP and File system
ARM966
CORE
E
w/DSP
96 MHz
DMA
PFQ
BC
INTR
Cntl
CLK
Cntl
LVD
BOD
PLL
ADC
RTC
64K or 96K
Byte SRAM
256K or 512K
Byte Burst Flash
32K Byte
Burst Flash
JTAG ETM9 OTP
Mem
TIM
SPI
I2C
Enet
MAC
USB
2.0FS
CAN
2.0B
GPIO
EXT.
Bus
UART
SSP
MS_uC / fue1 / V08
4- 2
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
SSP Hardware flow control
SSP
MS_uC / fue1 / V08
4- 3
Data input
parallel
7
Data input
parallel
Clock generator
0
7
0
Data output
parallel
Date output
parallel
Participant 1
Participant n
SSP features
SSP
MS_uC / fue1 / V08
4- 4
 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”
SSP Block diagram
SSP
MS_uC / fue1 / V08
4- 5
SSP Pin description
SSP
MS_uC / fue1 / V08
4- 6
SSP register map
SSP
MS_uC / fue1 / V08
4- 7
SSP Configuration (1/3)
SSP
MS_uC / fue1 / V08
4- 8
 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
SSP Configuration (2/3)
SSP
MS_uC / fue1 / V08
4- 9
 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
SSP Configuration (3/3)
SSP
MS_uC / fue1 / V08
4- 10
Pin connections of SSP
SSP
MS_uC / fue1 / V08
4- 11
 Use the SD Card adapter of MCBSTR9. Which port?
P5.4 UART0_SCLK Alternate Output 2
P5.5 UART0_MOSI Alternate Output 2
P5.6 UART0_MISO Alternate Input 1
P5.7 GPIO_5.7 Alternate Output 1
STR91x ARM966 manual 12274.pdf, 4.1 pin functions page 36
File system (FS)
SSP
MS_uC / fue1 / V08
4- 12
 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
Type of FS
SSP
MS_uC / fue1 / V08
4- 13
 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)
Secure Digital (SD) Memory Card
SSP
MS_uC / fue1 / V08
4- 14
 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
Pin assignments
SSP
MS_uC / fue1 / V08
Pin no.
4- 15
Symbol
Direction
In
Description
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
Structure of FAT partition disc
SSP
MS_uC / fue1 / V08
4- 16
Boot File
File
Root
Data Region
sector Allocation Allocation Directory
(for files and directories)
Table 2
Table 2
(FAT12/16 only)
 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
File Allocation Table (FAT)
SSP
MS_uC / fue1 / V08
4- 17
 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
File Allocation Table (example)
SSP
MS_uC / fue1 / V08
4- 18
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
Directory table
SSP
MS_uC / fue1 / V08
4- 19
 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
SSP
MS_uC / fue1 / V08
4- 20
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");
}
FILE
*fopen (char filename[], char mode[])
SSP
MS_uC / fue1 / V08
4- 21
 First argument of the fopen function
File name
 Second argument of the fopen function
Access type
"r"
"w"
"a"
"r+"
"w+"
"a+"
Open the file for read
Create the file for write
Create or open the file for write at the end of it
Open the file for update (read and write)
Create the file for update
Create or open the file for update at the end of it
int fclose (FILE *stream)
SSP
MS_uC / fue1 / V08
4- 22
 When the file will not be used
The link to the file must be close with fclose()
 Example
fclose (FilePointer);
SSP
MS_uC / fue1 / V08
4- 23
Function to read from or print
into files
Key board/screen
Function
printf("v = %d", i) Formatted
output
scanf("%f", f)
Formatted
input
c = getchar()
Read a
character
putchar(c)
Write a
character
gets(Buffer)
Read a
sentence
puts(Text)
Write a
sentence
File
fprintf(FilePointer, "v = %d", i)
fscanf(FilePointer, "%f", f)
c = fgetc(FilePointer)
fputc(c, FilePointer)
fgets(Buffer,Maxlength,FilePointer)
fputs(Text, FilePointer)