This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Updating values in memory

Other Parts Discussed in Thread: HALCOGEN

I'm trying to run code on my TI hercules launchpad TMS570LC43x that runs a sequence of pulses infinitely. Right now I'm writing to memory locations in the C code through CCS. I've set up an array that hold these values. Problem is everytime I update the array I have to recompile. I want to be able to set up my code so that I can update these array values via HTTP through the ethernet without having to recompile the code and reload to the TI, OR have a text file stored on a drive somewhere and the C code should read the text file and update the pulse values after every sequence.

My Sys_Main looks like this currently:

void main(void)
{
/* USER CODE BEGIN (3) */
////INITIALISE VARIABLES
int i=0;
int in_PULSE_VALUES[]={10,15,20,30,40,60,80,100,120,140,160,170,180,190,200};
int norm_PULSE_VALUES[15];
int Dead_Time=10;
int Enable=1;
////CONVERT PULSE VALUES FROM DECIMAL NORMALIZED CLOCK VALUES

for (i=0;i<15;i++)

{
norm_PULSE_VALUES[i] = round((in_PULSE_VALUES[i]/13.33)*1000);

}

/////////////initialize PWM

hetInit();

////// First PULSE INIT

e_HETPROGRAM0_UN.Program0_ST.hetlabel_30_0.memory.data_word=norm_PULSE_VALUES[0];
e_HETPROGRAM0_UN.Program0_ST.PULSMON_0.memory.data_word=norm_PULSE_VALUES[0];

//////////////// DEAD TIME INIT
e_HETPROGRAM0_UN.Program0_ST.hetlabel_31_0.memory.data_word=Dead_Time;
e_HETPROGRAM0_UN.Program0_ST.PULSMOFF_0.memory.data_word=Dead_Time;

/////////////// ON TIME INIT

e_HETPROGRAM0_UN.Program0_ST.hetlabel_54_0.memory.data_word=norm_PULSE_VALUES[1]; // 2 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_56_0.memory.data_word=norm_PULSE_VALUES[2]; // 3 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_58_0.memory.data_word=norm_PULSE_VALUES[3]; // 4 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_60_0.memory.data_word=norm_PULSE_VALUES[4]; //5 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_62_0.memory.data_word=norm_PULSE_VALUES[5]; // 6 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_64_0.memory.data_word=norm_PULSE_VALUES[6]; // 7 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_66_0.memory.data_word=norm_PULSE_VALUES[7]; // 8 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_68_0.memory.data_word=norm_PULSE_VALUES[8]; // 9 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_70_0.memory.data_word=norm_PULSE_VALUES[9]; // 10 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_72_0.memory.data_word=norm_PULSE_VALUES[10]; // 11 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_74_0.memory.data_word=norm_PULSE_VALUES[11]; // 12 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_76_0.memory.data_word=norm_PULSE_VALUES[12]; // 13 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_78_0.memory.data_word=norm_PULSE_VALUES[13]; // 14 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.PULSFIN_0.memory.data_word=norm_PULSE_VALUES[14]; // 15 PULSE VALUE

//////////////////////////////////LOOP TO KEEP PULSE GOING FOREVER
while(1)
{
while (0 != e_HETPROGRAM0_UN.Program0_ST.START_0.memory.data_word);

//10 microsec pause
for (i=0;i<280;i++) {};

e_HETPROGRAM0_UN.Program0_ST.START_0.memory.data_word=0x80; // TELLS THE CODE WHERE TO LOAD THE HET PROGRAM

////// First PULSE INIT

e_HETPROGRAM0_UN.Program0_ST.hetlabel_30_0.memory.data_word=norm_PULSE_VALUES[0];
e_HETPROGRAM0_UN.Program0_ST.PULSMON_0.memory.data_word=norm_PULSE_VALUES[0];

//////////////// DEAD TIME INIT
e_HETPROGRAM0_UN.Program0_ST.hetlabel_31_0.memory.data_word=Dead_Time;
e_HETPROGRAM0_UN.Program0_ST.PULSMOFF_0.memory.data_word=Dead_Time;

/////////////// ON TIME INIT

e_HETPROGRAM0_UN.Program0_ST.hetlabel_54_0.memory.data_word=norm_PULSE_VALUES[1]; // 2 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_56_0.memory.data_word=norm_PULSE_VALUES[2]; // 3 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_58_0.memory.data_word=norm_PULSE_VALUES[3]; // 4 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_60_0.memory.data_word=norm_PULSE_VALUES[4]; //5 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_62_0.memory.data_word=norm_PULSE_VALUES[5]; // 6 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_64_0.memory.data_word=norm_PULSE_VALUES[6]; // 7 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_66_0.memory.data_word=norm_PULSE_VALUES[7]; // 8 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_68_0.memory.data_word=norm_PULSE_VALUES[8]; // 9 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_70_0.memory.data_word=norm_PULSE_VALUES[9]; // 10 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_72_0.memory.data_word=norm_PULSE_VALUES[10]; // 11 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_74_0.memory.data_word=norm_PULSE_VALUES[11]; // 12 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_76_0.memory.data_word=norm_PULSE_VALUES[12]; // 13 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.hetlabel_78_0.memory.data_word=norm_PULSE_VALUES[13]; // 14 PULSE VALUE
e_HETPROGRAM0_UN.Program0_ST.PULSFIN_0.memory.data_word=norm_PULSE_VALUES[14]; // 15 PULSE VALUE

}

What is the best way to do what I need, and how can I do this?

Thanks

  • Updating the values through Ethernet will require a lot of code to be added to your project. Using CIO causes the processor to be stopped while CCS does the file read. Consider using the SCI to PC com port that is part of the USB/JTAG interface already on the Launchpad. You would have to add code to your project to read the values coming from the SCI and store them, then update the array at the end of the sequence. You could use a terminal emulator program to send the values (in a file) to the MCU whenever you want to change them.
  • How do I use the SCI to PC Com port? What steps would I take in halcogen and then what code should I add to my C code? I' m mostly new at all this and dont really know it too well.

    Thanks
  • Hi,

     Bob is out of office since last week.

     Here is one example to setup the UART to communicate with your PC.  You need to open a terminal on your PC. I use HyperTerminal. CCS also supports terminal. In CCS you can go to View->Other->Terminal->Terminal.  This example setup the terminal for 9600 baud rate, no parity and 2 stop bits and no hardware flow control.

     As you can see in the first image, in the terminal I type in 12345678909876543210. The string is received by the SCI module and the data is stored in the receive_buff. See the second image for the receive_buff array.

    The example is attached here. Once the data is received by the MCU it is up to your application what to do with it. You can use the recieved data to setup the NHET PWM period and duty. The HalCoGen setup is also included in the project. The example uses interrupt mode. I will also be out of office starting tomorrow. Bob should be back and can follow up with you.

    3010.LC4357_UART_9600.zip