bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
Certainly you are not referring to UART1_Write() but rather to UART1_Write_Text(), which accept arguments as pointer of an array. Anyway, why should both functions work likewise ? Apropos, you can make your own function SPI1_write_Text() building with the SPI1_write() inside, although a priori would not make much sense, once AFAIK most SPI packs sent by Master device are shorts.
Why can't I transfer data on SPI1_Write().....but it's transfered ok on UART ??
I'm giving you an example of what I meant at the code posted on the following thread, on which you can see that the function UART1_Write() was used to send a single character, whereas the function UART1_Write_Text() was used to send a string:
void MP3_SDI_Write(char data_) {
MP3_CS = 1;
//while (DREQ == 0); // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI
BSYNC = 0;
UART1_Write(data_);
//SPI1_Write(data_);
BSYNC = 1;
}
void Read_Play_MP3()
{
unsigned long i, fsize;
unsigned int j, cnt,count;
short fhandle;
char readBuffer[BUFSIZE];
char str[55];
LED = 0;
fhandle = FAT32_Open("hello.mp3", FILE_READ);
if (fhandle >= 0)
{
UART1_Write_Text("File test1.mp3 opened sucessfully!\n");
FAT32_Size("hello.mp3", &fsize);
LongToStr(fsize, str);
UART_Write_Text("hello.mp3 size: ");
UART_Write_Text(str);
UART_Write(CR);
while (FAT32_Eof(fhandle) != 1)
{
FAT32_Read(fhandle, readBuffer, BUFSIZE);
count =0;
while(count<512)
{
for(j=0;j<32;j++)
{
if (DREQ == 1)
{
MP3_SDI_Write(readBuffer[count]); //????
//UART_Write(readBuffer[count]); //????
count++;
}
}
//Delay_ms(10);
}
LED = 1;
Delay_ms(100);
LED = 0;
}
UART1_Write_Text("\nDone !\n DONE! \n");
LED = 1;
Delay_ms(1000);
LED = 0;
FAT32_Close(fhandle);
}
else
{
UART1_Write_Text("Opening file hello.mp3 failure!\n");
}
}
when I used SPI1_Write(), it's sending only 512bytes....
When I used UART1_Write()...it can send the whole files perfectly...
How exactly? Signalling eof after 512 bytes? or?only 512 bytes...not complete file...
Sending bytes to what ?
If worked for 512 bytes, you are missing to analyse the part of the code that calls the function MP3_SDI_Write().
How exactly? Signalling eof after 512 bytes? or?
Not answering the question.
You see eof after 512 bytes although the file is larger than 512 bytes?
Why don't you report your observation clearly from the start?but if I used SPI it can not see EOF only the first 512 bytes and repeat
Why don't you report your observation clearly from the start?
Most likely, from the second function call, FAT32_Read() simply does nothing, the initially read sector data is preserved. You're ignoring the result of FAT32_Read() and don't become aware of it's failure.
Question is of course why file read is failing, a specific reason can't be seen in the code. I guess there might be an unexpected side effect of SPI1_write() on the SD card SPI interface. Either a problem in your code or a bug of the MikroC built-in libraries.
MP3_CS = 1;
Zip and post the complete project. Remove all unnecessary codes.
I use EasyMx Pro for STM32 from mikroE.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?