DSPI master transfer sends the same value when used inside PIT interrupt ISR.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DSPI master transfer sends the same value when used inside PIT interrupt ISR.

1,292 Views
InHome
Contributor III

Dear NXP,

I am working on DSPI communication with the KIT20XS4200EVBE using the MPC5748G calypso microcontroller.

I have a problem with the DSPI_MasterTransfer function and, I don't have any idea why my oscilloscope captures the same frame.

I am using the S32DS design to generate the code using the graphical interface offered by NXP. I have a PIT interrupt coming each 10ms. in the interrupt service routine, I call des_MC20XS4200_PwmUpdate. in the des_MC20XS4200_PwmUpdate function, I  use the DSPI_MasterTransfer(INST_DSPI1, ptr, RXbuffer, 1); to send the pointer to the uint16 variable. 

My buffer has one value to send and receive.

 

 

 

 

uint16_t des_MC20XS4200_PwmUpdate(XS_SpdInRegsDataPtr XS_SpdInRegsData, uint16_t duty)
{
	uint16_t status;
	uint16_t channel;
	uint16_t *ptr;
	uint16_t des_status = STATUS_SUCCESS;

	//watchDog = 0;
	for (channel = 0; channel < XS_MAX_HS; channel++)
	{
		XS_SpdInRegsData[channel].XS_PwmIn.u3RAddr 		 = XS_SPD_PWMR_ADDR;
		XS_SpdInRegsData[channel].XS_PwmIn.u8PWM		 = (uint8_t)0x00ff&duty;
		XS_SpdInRegsData[channel].XS_PwmIn.u1A0 		 = channel;
		XS_SpdInRegsData[channel].XS_PwmIn.u1WDIN	     = watchDog;
		XS_SpdInRegsData[channel].XS_PwmIn.u1P 			 = u16_XS_iParityCalc((uint16_t)XS_SpdInRegsData[channel].XS_PwmIn.All);

		ptr = (uint16_t*)&XS_SpdInRegsData[channel].XS_PwmIn.All;
		des_status = DSPI_MasterTransfer(INST_DSPI1, ptr, RXbuffer, 1);

		watchDog ^=1;

	}

	return status;
}

 

 

 

 

My issue is when I break the counter execution in line 130(just before calling the DSPI_MasterTransfer ), I could see that my variable is changing, but in the scope inspector, the DSPI send always the same value.

*ptr = 0x88FF in the first iteration of the for loop

*ptr = 0x28FF in the second iteration of the for loop.

In the SPI scope inspector, I have this frame.

InHome_0-1634417988006.png

0ms I have this  frame, 

InHome_0-1634467721102.png

 

in 10ms I have the same TX frame.

InHome_1-1634467746315.png

 

 

 

I pushed my code to git if you want to see the project.

https://gitlab.com/tarik_semrade/mcxs2000.git

Thank you in advance for you help,

S.Tarik

 

 

 

 

Tags (1)
0 Kudos
Reply
3 Replies

1,244 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

try to rewrite your code as below

PetrS_0-1634626628314.png

then both words will be send 

PetrS_1-1634626687351.png

 

BR, Petr

0 Kudos
Reply

1,231 Views
InHome
Contributor III

Hello Petr,

 

Thank you for your replay,

Your proposition works for me and, I have another solution for this issue using the code I posted.

The solution is to use a flag in the ISR and add an infinite loop in the main function with a test on that flag to call the function every 10ms... 

The thing is the DSPI uses the interrupt for receiving and transmitting, my idea is related to nested interrupts.

I am not sure but, I think that in the PIT interrupt other interrupts are maskable and the transmission is established after coming out of the PIT ISR.

What do you think?

Thank you!

S.Tarik

0 Kudos
Reply

1,226 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Seems interrupts are enabled again within IVOR4_Handler, so nesting is enabled, thus interrupts with higher priority can be called.

BR, Petr

0 Kudos
Reply