Hi,
I am working with the tms320f2812 controller to be programmed via the serial port. I have all the hardware it needs including the edsp starter kit and the link research module used in "TMS320F281x Boot ROM Serial Flash Programming" and it works fine with the computer. The computer is able to transfer the CKFA file and the appcode to the TMS320F2812 using the serial port. But my task includes making this work with a microcontroller.
The micro controller I am using the Microchips 18F4620, which has 2 serial ports. At the end of the day, I would like the user to send the data through one of the serial ports to the microcontroller, which then transferrs the data to the Edsp board using the 2nd serial port. It all sounds simple, here is where the complication lies.
When the CKFA software is running, the DSP displays the following:
///////////////////////////////
Processor is unlocked.
Communication kernel received and executing.
Type 'a' to relock baud-rate:
/////////////////////////////
when 'a' is typed, the baud rate is relocked again and the following display appears :
/////////////////////////////
Flash Checksum = 0xB98B
FLASH is not erased and should not be programmed until it is erased.
Erase FLASH? (y/n): y //user input
Erasing ... please wait ** erasing done
///////////////////////////////
So when a micro is attached on the other end, it would not be able to work with that, so I tried to modify the CKFA code so that the software does not ask for user inputs and just programs the data, but the problem is I cant seem to do it. What ever I try the CKFA comes to :
/////////////////////////////
Processor is unlocked.
Communication kernel received and executing.ׂþ
////////////////////////////
and STOPS.
Here is a segment of the code I am running, kindly let me know if I am doing anything wrong.
//////////////////////////////////
void main2(void)
{
Uint16 ErrorFlag, temp, Status;
/*------------------------------------------------------------------
To use the F2812, F2811 or F2810 Flash API, the following steps
must be followed:
1. Modify Flash281x_API.config.h for your targets operating
conditions.
2. Include Flash281x_API_Library.h in the application.
3. Add the approparite Flash API library to the project.
The user's code is responsible for the following:
4. Initalize the PLL to the proper CPU operating frequency.
5. If required, copy the flash API functions into on-chip zero waitstate
RAM.
6. Initalize the Flash_CPUScaleFactor variable to SCALE_FACTOR
7. Initalize the flash callback function pointer.
8. Optional: Run the Toggle test to confirm proper frequency configuration
of the API.
9. Optional: Unlock the CSM.
10. Call the API functions: Flash_Erase(), Flash_Program(), Flash_Verify()
The API functions will:
Disable the watchdog
Check the device revision (REVID). This API is for Revision C silicon
Perform the desired operation and return status
------------------------------------------------------------------*/
SCI_SendStatus("Communication kernel received and executing.");
// SCI_SendStatus("\n\rType 'a' to relock baud-rate: "); // This line was previously functional
/*------------------------------------------------------------------
Initalize the PLLCR value before calling any of the F2810, F2811
or F281x Flash API functions.
Check to see if the PLL needs to changed
PLLCR_VALUE is defined in Example_Flash281x_API.h
1) Make the change
2) Wait for the DSP to switch to the PLL clock
This wait is performed to ensure that the flash API functions
will be executed at the correct frequency.
3) While waiting, feed the watchdog so it will not reset.
------------------------------------------------------------------*/
initPLL();
/*------------------------------------------------------------------
Initalize Flash_CPUScaleFactor.
Flash_CPUScaleFactor is a 32-bit global variable that the flash
API functions use to scale software delays. This scale factor
must be initalized to SCALE_FACTOR by the user's code prior
to calling any of the Flash API functions. This initalization
is VITAL to the proper operation of the flash API functions.
SCALE_FACTOR is defined in Example_Flash281x_API.h as
#define SCALE_FACTOR 1048576.0L*( (200L/CPU_RATE) )
This value is calculated during the compile based on the CPU
rate, in nanoseconds, at which the algorithums will be run.
------------------------------------------------------------------*/
Flash_CPUScaleFactor = SCALE_FACTOR;
/*------------------------------------------------------------------
Initalize Flash_CallbackPtr.
Flash_CallbackPtr is a pointer to a function. The API uses
this pointer to invoke a callback function during the API operations.
If this function is not going to be used, set the pointer to NULL
NULL is defined in <stdio.h>.
------------------------------------------------------------------*/
//// the lines below were previously functional in the original code
// Flash_CallbackPtr = &MyCallbackFunction;
// MyCallbackCounter = 0; // Increment this counter in the callback function
//Prep SCI with new baud rate
/* SCIA_Init(); Tirtho
SCIARegs.SCIFFTX.bit.SCIFFENA = 0;
SCIA_AutobaudLock();
SCIARegs.SCICTL1.bit.SWRESET = 0;
SCIARegs.SCICTL1.bit.SWRESET = 1;
SCIARegs.SCIFFTX.bit.SCIFFENA = 1;
SCIARegs.SCIFFTX.all &= 0x7FFF;
SCIARegs.SCIFFTX.all |= 0x8000;
SCI_SendStatus(" baud-rate relocked\n\r\r ");
*/
//Erase flash
temp = checksum_flash(); // I would like to jump to this segment of the code, but it does not seem to do so.
tempL = Convert_HEXtoASCII(temp);
SCI_SendStatus("\n\n\rFlash Checksum = 0x");
SCI_SendHexLong(tempL);
if(temp==0)
SCI_SendStatus("\n\rFLASH appears to be erased already.");
else
SCI_SendStatus("\n\rFLASH is not erased and should not be programmed until it is erased.");
SCI_SendStatus("\n\n\rErase FLASH? (y/n): ");
temp = 1; //intially it was "temp = SCIA_GetByteData_app();"
if( temp == 1)//initially it was "if( temp != 'n')" Tirtho
{
SCI_SendStatus("\n\rErasing ... please wait");
#if FLASH_F2810
Status = Flash_Erase(SECTOR_F2810,&EraseStatus);
#endif
#if FLASH_F2811 | FLASH_F2812
Status = Flash_Erase(SECTOR_F2812,&EraseStatus);
#endif
if(Status != STATUS_SUCCESS)
{
SCI_SendStatus("\n\r Flash Erase Error ");
Example_Error(Status);
}
SCI_SendStatus(" ** erasing done\n\r");
}
//Transfer and program application code
SCI_SendStatus("\n\rReady for application data transfer...\n\r");
SCIA_BlockProcessing();
//Calculate new checksum and compare with expected value
SCI_SendStatus(" ** application programmed");
temp = checksum_flash();
tempL = Convert_HEXtoASCII(temp);
SCI_SendStatus("\n\rFlash Checksum = 0x");
SCI_SendHexLong(tempL);
ErrorFlag = temp - CHECKSUM_EXPECTED;
if(ErrorFlag)
{
SCI_SendStatus(" ** checksum error ");
Example_Error(100);
}
SCI_SendStatus(" ** checksum verified ");
//CKFA software done
///////////////////////////////////////////////////
void initPLL(void)
{
int i;
if(*PLLCR != PLLCR_VALUE)
{
EALLOW;
*PLLCR = PLLCR_VALUE;
// Wait for PLL to lock
// Each time through this loop takes ~14 cycles
// PLL Lock time is 131072 Cycles
for(i= 0; i< 131072/14; i++){
//*WDKEY = 0x0055;//The omitted lines were present in the original code
//*WDKEY = 0x00AA;
*WDCNTR = 0x0000;// NEW Code, cleared the watchdog counter, since we are not using an input key from the user.
}
for(i= 0; i< 131072/14; i++){
//*WDKEY = 0x0055;
//*WDKEY = 0x00AA;
*WDCNTR = 0x0000;// NEW Code, cleared the watchdog counter, since we are not using an input key from the user.
}
EDIS;
}
return;
}
///////////////////////////////////////////
I would be glad if anyone could help me out.
Thanks
T