i dont do c but need help in understanding what this bit of code does. i am only interested in the sendmmc() function. does it send the command Command(0x51,0,512,0xFF) then send 512 * ff on spi bus or send the comand 512 times ?
David
bit sendmmc() // send 512 bytes from the MMC via the serial port { uns16 i; // 512 byte-read-mode if (Command(0x51,0,512,0xFF) !=0) { SerString("MMC: read error 1 "); return 1; } while(SPI(0xFF) != 0xFE); // wait for 0xFE - start of any transmission for(i=0; i < 512; i++) { while(!TXIF); // wait until TXREG is empty TXREG = SPI(0xFF); // get MMC byte and send via RS232 } serialterminate(); SPI(0xFF); // at the end, send 2 dummy bytes SPI(0xFF); return 0; }
void main(void) { InitUSART(); // initialize serial port initint(); // initialize interrupts
ADCON1=0x6; // PortA Digital // set ports for I/O TRISC = 0b.1101.0011; // sck rc3-0, sdo rc5-0, CS rc2-0. TRISB = 0b.0000.0010; // RB2>TX, RB1>RX
SerString("PIC online "); // start message // SerString(0x00); // start message
// init MMC and send message if ok if (MMC_Init()) SerString("MMC online ");
fillram(); // fill the RAM with ASCII characters writeramtommc(); // write RAM to MMC sendmmc(); // send 512 bytes of the MMC via serial port
while(1) { nop(); nop(); } }