Datasheet

// if defined, we have a debug messages on PC terminal
#define RS232_debug 1
sbit Mmc_Chip_Select at PORTG.B1;
sbit Mmc_Chip_Select_Direction at DDRG.B1;
// universal variables
unsigned int px, k; // universal for loops and other stuff
// Variables for MMC routines
unsigned char dData[512]; // Buffer for MMC sector reading/writing
unsigned char data_for_registers[16]; // buffer for CID and CSD reg-
isters
// RS232 communication variables
unsigned char received_character;
unsigned long sector_address;
unsigned char first_byte, second_byte, third_byte, fourth_byte;
unsigned char serial_buffer[2];
unsigned char serial_pointer;
// Display byte in hex
void printhex(unsigned char i) {
unsigned char hi,lo;
hi = i & 0xF0; // High nibble
hi = hi >> 4;
hi = hi + '0';
if (hi>'9') hi = hi + 7;
lo = (i & 0x0F) + '0'; // Low nibble
if (lo>'9') lo=lo+7;
UART1_Write(hi);
UART1_Write(lo);
}
char (*Spi_Rd_Ptr)(char) = SPI1_Read;
void main()
{
unsigned int i;
PORTC = 0;
#ifdef RS232_debug
UART1_Init(19200);
#endif
Delay_ms(10);
336
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6