Codewarrior Expert SPI Events

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

Codewarrior Expert SPI Events

750 Views
luca_ferrario
Contributor II

Hi!

I've a problem with the expert code generator and SPI, I've setted SM1 SyncroMaster in this way:

pastedImage_1.png

Board: DEVKIT-S12ZVC

My problem is that I don't see any event triggerd or any output on the pins (SCK, MOSI, MISO) and I am using for testing:

SM1_SendChar(0);          // Send zero

After 8 bit the senChar() function reply with ERR_TXFULL error. So No data is trasferred from the TX buffer.

There is something wrong in my settings?

Thank you!!

Tags (2)
2 Replies

618 Views
luca_ferrario
Contributor II

Hi,

I think I find the problem: if I enable Interrupt service, the output doesn't works and no event (or SM1 interruput) is triggered.

There is a way to fix it? Or only by registers?

Thank you!

0 Kudos

618 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Luca,

I recommend you a few options: disable interrupts for the SM1 component or you can look at the S12ZVC SPI example (attached) which uses the different PE component or you can write your own code.

Also, I would like to mention that the PE is not already supported and it won't be fixed.

Let me explain the behavior of SM1 component:

When you enable interrupt in SM1 component the Processor Expert generates SM1_SendChar() function where is set the SerFlag. But this flag is cleared only in the ISR(SM1_Interrupt) routine. This interrupt is generated when the SPI Transmit Empty Interrupt Flag (SPTEF) is set. 

So, in the case, the SPI Transmit Interrupt is disabled (SPTIE), you will always get the ERR_TXFULL because the SerFlag is not cleared anymore.

In case, the SPI Transmit Interrupt is enabled (SPTIE), it will always go to the ISR(SM1_Interrupt) routine (whenever the data register is empty and ready to accept new data). Therefore, SPTIE should be disabled in the ISR(SM1_Interrupt), but we cannot change the generated code. So, that is why it is working only when you disable SPI interrupt.

I hope it helps.

Best regards,

Diana