hello eveyone,
I'm trying to make a simulation of SD card with ISIS Proteus , the code for the Microcontrolleur is in C langage! but I don't know why i don't get something in the virtual terminal !!! help mee pleaaazz!!!
// This function sends carriage-return and line-feed to USART//
sfr sbit Mmc_Chip_Select at RC2_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISC2_bit;void Newline(){
Soft_Uart_Write(0x0D);// Send carriage-return
Soft_Uart_Write(0x0A);// Send line-feed}//// This function sends a space character to USART//void Space(){
Soft_Uart_Write(0x20);}//// This function sends a text to serial port//void Text_To_Usart(unsignedchar*m){unsignedchar i;
i =0;while(m[i]!=0){// Send TEXT to serial port
Soft_Uart_Write(m[i]);
i++;}}//// This function sends string to serial port. The string length is passed as an argument//void Str_To_Usart(unsignedchar*m,unsignedchar l){unsignedchar i;unsignedchar txt[4];
i=0;for(i=0; i<l; i++){
ByteToStr(m[i],txt);
Text_To_Usart(txt);
Space();}}//// Start of MAIN program//void main(){unsignedchar error,CID[16];unsignedchar msg[]="S";//// Configure the serial port//
Soft_Uart_Init(PORTC,7,6,2400,0);// TX=RC6//// Initialise the SD card//
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);//// Initialise the SD bus//while(Mmc_Init());//// Start of MAIN loop. Read the SD card CID register and send the data// to serial port every 10 seconds//for(;;)// Endless loop{
Text_To_Usart(msg);// Send TEXT
Newline();// Send newline
Newline();// Send newline
error = Mmc_Read_Cid(CID);// Read CID register into CID//// Send the data to RS232 port//
Str_To_Usart(CID,16);// Send CID contents to UART
Delay_Ms(10000);// Wait 10 seconds
Newline();
Newline();}}