64MB MMC and PIC Micro Controller
64MB MMC and PIC Micro Controller
64MB MMC and PIC Micro Controller
MMC memory card with PIC16F877 letter of a Multimedia Card (MMC) at each
PIC Mikrocontroller /Lesen over mirror-image interface (MMC 64MB and PIC
Microcontroller) a software related mirror-image interface makes possible the
connection. Connection diagram, theory about mirror-image interface, theory
about MMC, signal diagrams, program in C (CC5X).
+
MMC (Multimedia Card) here The PIC16F877 has:
64MB. - Mirror-image interface
- Enormous FLASH - memory. - RS232 interface
- Very fast. - of 8 entrances for the similar to/digital
-300000 write accesses. transducer (10Bit)
- Vintages without restriction.
- Connection to the SPADES with 4
lines.
Pin Contraction Function Pin Contraction Function
1 /CS Chip activating 18 RC2 Digitally OUT
2 DATA IN Data input 24 SDO MIRROR-IMAGE data
output
3 GND - - - -
4 Vdd Voltage supply - - -
5 CLK Clocking line 18 SCL MIRROR-IMAGE
Clock
6 GND - - - -
7 DATA OUT Data output 23 SDI MIRROR-IMAGE data
input
Circuit and connection diagram MMC need as voltage supply 2,7V 3,6V. We
must use an in any case voltage regulator for 3,3V, for example CS5203. PIC
processors can be operated with tensions between 2V and 5,5V. Thus one
could agree with the supply of both units on 3,3V. Then it is also possible to
connect MMC directly with the micro CONTROLLER. Due to considerations that
the AD transducer and serial communication with 5V functions more stably it is
operated, in this circuit of the PIC16F877 nevertheless with 5V. But the micro
CONTROLLER exits SDO, SCL, /CS get in each case a voltage divider, so that
the MMC entrances receive only 3,2V. The entrances of the microprocessor do
not need reinforcement of 3,3V on 5,0V, because the PIC understands 3,3V
anyway as logical "1"
.
The
#include <C:\cc5\16F877.H>
// Speicherschutz 12-13-4-5=aus, Debug 11=aus,ProgrammFlash 9=an,
EEpromRead 8=an, NiederVoltProgr 7=aus
// NiederVoltReset 6=an, EinschaltTimer 3=an, WachDogTimer 2=aus,
Oszilator 01=XC
#pragma config |= 0b.11.111101.11.00.10
void InitUSART()
{
BRGH=1; // Hohe Geschwindigkeit für Datenübertragung
//SPBRG=129; // (9600 baud @ 20MHz input clock)
//SPBRG=64; // (19200 baud @ 20MHz input clock)
//SPBRG=32; // (38400 baud @ 20MHz input clock)
SPBRG=10; // (115200 baud @ 20MHz input clock)
SPEN = 1; // Set_Serial_Pins;
SYNC = 0; // Set_Async_Mode;
TX9 = 0; // Set_8bit_Tx;
RX9 = 0; // Set_8bit_Rx;
CREN = 1; // Enable_Rx;
TXEN = 1; // Enable_Tx;
RCIE=0; // Rx Interrupt aus
}
//********************************************************************
**
bit MMC_Init()
{
// Init SPI
SMP=0; // Input ist gültig in der Mitte des Clock's
CKE=0; // Bei steigender Flanke Datenübernahme
CKP=1; // High ist passiver Zustand
SSPM1=1; // Geschwindigkeit f/64(312kHz), Master
//SSPM0=1; // Geschwindigkeit f/16(1,25MHz), Master
SSPEN=1; // SPI Ein
CS=1; // MMC-Disabled
char i; // Variablen
// CMD0
if (Command(0x40,0,0,0x95) !=1)goto Fehler ; // Reset
return 1;
Fehler:
return 0;
}
//********************************************************************
******
void main(void)
{
INTCON=0; // Interrupts aus
ADCON1=0x6; // PortA Digital
TRISC=0b.1101.0011; // sck rc3-0, sdo rc5-0, CS rc2-
0.
TRISB=0b.0000.0010; // RB2>TX, RB1>RX
uns16 i; // Variable 0...65535
InitUSART(); // Serielle Datenübertragung
initialisieren
SerString("Ich bin ON "); // Startmeldung
if (MMC_Init()) SerString("MMC ON "); // MMC Initialisieren und
Meldung falls OK!
//********************************************************************
**********
//********************************************************************
**
while(1); //hier bleibt Programm stehen
}
Program sequence
first those of haven are adjusted. Then the serial interface initialized with
115200 Baud, no parity bit, 1 stop bit and the message: "I am ON" spent.
Afterwards MMC one initializes; if that is successful, then the message
becomes: "MMC ON" spent. Next 512 byte is read in and sent serially to the
PC. Afterwards 512 byte with the indication ' M ' is described. One writes and
one reads starting from address 512. Starting from address 512 the reserved
range begins when formatting with FAT16, so that even the data and file system
on your MMC map remain. With errors the following messages can occur: -
"Lese_resp_Fehler" - no answer to instruction read, - "Schreib_resp_Fehler" -
no answer to instruction write, - "Schreib_Fehler" - after the recording procedure
no confirmation. With this program each address can be described and read.
One can stop the read block size at will. Here are signal diagrams of the
recording procedure and reading. To the Download: Connection diagram
+Quellkode +Hex file
All PIC types does not have the mirror-image interface, therefore I wrote a
subroutine, which makes mirror-image communication possible with each PIC
Mikrocontroller. With the program one can select the pins for the mm approx.
conclusion freely. This selection happens on the beginning of the program:
At lower clock frequencies the program works, only also more slowly. MMC
starts itself to attach: PIC16F870, PIC16F871, PIC16F872, PIC16F873,
PIC16F874, PIC16F876, PIC16F877, PIC16F84, PIC12F675, PIC12F629. Here
is a program for tests the software related MIRROR-IMAGE interface with
MMC. It is adapted for the PIC16F877, because I did not want to change the
hardware. Open questions: - MMC byte takes to the letter only blocks of 512,
where am I buffers? - as I can use FAT - table, in order to pick from a MMC
Kartenreader stored file out? On these questions I look for straight answer. If to
me somewhat occurs place I in the context of my web page here in here.
Buffers? One does not need, because one can transfer each byte with arbitrary
speed to the MMC, even 1 byte per hour. It is only stored only after 512 byte.