Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help:SD card Simulation with ISIS proteus

Status
Not open for further replies.

Momos1989

Junior Member level 2
Joined
Sep 26, 2012
Messages
24
Helped
1
Reputation
6
Reaction score
1
Trophy points
1,283
Activity points
1,439
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!!!

here is the code:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// 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(unsigned char *m)
{
unsigned char 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(unsigned char *m,unsigned char l)
{
unsigned char i;
unsigned char 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()
{
unsigned char error,CID[16];
unsigned char 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();
}
}


Captur4e.PNGCaptur4e.PNGCapture.PNG
Capture.PNG
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top