Other Parts Discussed in Thread: C2000WARE
I know this is not a Visual C++ forum but since TI provides the serial flash programmer I thought maybe someone could help. Here is the function
C:\ti\c2000\C2000Ware_4_01_00_00\utilities\flash_programmers\serial_flash_programmer\serial_flash_programmer\source\f021_DownloadKernel.cpp
void loadProgram(FILE *fh)
{
unsigned char sendData[8];
unsigned int fileStatus;
unsigned int rcvData = 0;
DWORD dwRead;
DWORD dwWritten;
getc(fh);
getc(fh);
getc(fh);
fileStatus = fscanf_s(fh, "%x", &sendData[0]);
float bitRate = 0;
DWORD millis = GetTickCount();
while (fileStatus == 1)
{
QUIETPRINT(_T("\n%lx"), sendData[0]);
//Send next char
WriteFile(file, &sendData[0], 1, &dwWritten, NULL);
bitRate++;
dwRead = 0;
//T1
while (dwRead == 0)
{
ReadFile(file, &rcvData, 1, &dwRead, NULL);
}
//T2
QUIETPRINT(_T("==%lx"), rcvData);
//Ensure data matches
if (sendData[0] != rcvData){
VERBOSEPRINT(_T("\nData does not match... Please press Ctrl-C to abort."));
while (1){}
}
//Read next char
fileStatus = fscanf_s(fh, "%x", &sendData[0]);
}
millis = GetTickCount() - millis;
bitRate = bitRate / millis * 1000 * 8;
QUIETPRINT(_T("\nBit rate /s of transfer was: %f"), bitRate);
rcvData = 0;
}
The baud rate is 115200 and characters are echoed back correctly. In free run the time between the markers is 15 ms which is way too long. However, if I pause the program at T1 and then let it read, the read takes 7 ms. The F28386S is echoing the character right away so it seems the delay is ReadFile().
Any ideas?
Thanks,
John