Hi,
I am trying to pass data from one CPU1 to CPU2 and vice-versa in the form of arrays. I have been successful in transferring data from CPU1 to CPU2, whereas it does not seem to work the other way around.
The two arrays, with #pragma statements for memory allocation are the following:
#pragma DATA_SECTION(mT,"Cpu1ToCpu2RAM") uint16_t mT[4]; #pragma DATA_SECTION(iT,"Cpu2ToCpu1RAM") uint16_t iT[2];
mT is updated in CPU1 and if passed to CPU2 in the following ISR, triggered by CPU1:
interrupt void probe_CPU2(void)
{
// stuff to ship to CPU2 dummy update --------------------
if((ISR_count1 % 40000) == 0){
slider1++;
slider2 += 2;
}
// Communicate with CPU2 via IPC
SendDataToCpu2 = slider1;
SendAddrToCpu2 = slider2;
IpcRegs.IPCSENDDATA = (Uint32) SendDataToCpu2; // Write the result to the IPC data register
IpcRegs.IPCSENDADDR = (Uint32) SendAddrToCpu2; // Write the result to the IPC addr register
IpcRegs.IPCSET.bit.IPC1 = 1; // Set the IPC1 flag for CPU2
RecDataFromCpu2 = (Uint16) IpcRegs.IPCRECVDATA; // Read data on IPC data register
RecAddrFromCpu2 = (Uint16) IpcRegs.IPCRECVADDR; // Read data on IPC addr register
// Arrays management
// Transfer modulation signals from CPU1 to CPU2
mT[0] = slider1;
mT[1] = slider2;
mT[2] = slider1;
mT[3] = slider2;
// data updated by CPU2 --- NOT WORKING!!!
input1 = iT[0];
input2 = iT[1];
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; // Acknowledge PIE group 3 to enable further interrupts
EPwm2Regs.ETCLR.bit.INT = 1; // Clear EPWM1_INT flag to allow further interrupts
}
This ISR sets the IPC1 flag for CPU2 to respond with the following ISR (where iT is modified):
interrupt void ipc1_isr(void)
{
// Read data from CPU1
temp1 = (Uint16) IpcRegs.IPCRECVDATA;
temp2 = (Uint16) IpcRegs.IPCRECVADDR;
// Send data back to CPU1 multiplied
IpcRegs.IPCSENDDATA = (Uint16) temp1*4; // send CPU2.CLA response back to CPU1
IpcRegs.IPCSENDADDR = (Uint16) temp2*4;
ISR_count1_cpu2++; // ISR coutner
if(ISR_count1_cpu2 % 20000 == 0){
dummy1++;
iT[0] = dummy1;
iT[1] = dummy1 + 1;
}
// Return from interrupt house keeping
IpcRegs.IPCACK.bit.IPC1 = 1; // Clear IPC1 bit
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge PIE group 1 to enable further interrupts
}
Debugging I have no problem in seeing mT updated correctly in CPU2. I can also see iT updated correctly in CPU2, however I cannot see any modification of iT seen by CPU1, as input1 and input2 variables remain always 0 and not updated with the actual new value of iT, which is indeed modified by CPU2.
It seems as if I can modify mT from CPU1 and make it visible to CPU2, and that is ok, whereas it seems that although I can modify iT array in CPU2 I cannot see that modification taking place for CPU1.
Any help would be really appreciated.
Many thanks,
Nicola