KE02 SPI Documentation

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

KE02 SPI Documentation

Jump to solution
804 Views
RobertoPaolinel
Contributor II

Hello,

2 issues on KE02 SPI reference manual I don't understand:

1) SPIx_S[MODF]: Immagine incorporata 1 What content should I write in C1?

2) SPIx_S[SPMF]

Immagine incorporata 1

The problem is that register is read only, as stated here.

Visualizzazione di image.png

So, how can I clear SPMF?

Best Regards

Roberto

Labels (1)
Tags (1)
0 Kudos
1 Solution
618 Views
isaacavila
NXP Employee
NXP Employee

Hello Roberto,

  • In order to clear SPIx_S[MODF] flag you need to write any value that you want to SPIx_C1 register, I would suggest to set the SPIx_C1[MSTR] bit due when MODF bit is set, SPI module is configured as slave and MSTR value is cleared, so you can enable this bit again:
if (SPI0->S & SPI_S_MODF_MASK)
{    
    uint8_t temp = SPI0->C1 | SPI_C1_MSTR_MASK;
    SPI0->C1 =  temp;
}‍‍‍‍‍

Or simply:

if (SPI0->S & SPI_S_MODF_MASK)
{
    SPI0->C1 |= SPI_C1_MSTR_MASK;
}

Remember that in order to clear this flag, MODF condition must be removed (SS input should detect a high level voltage), otherwise, this MODF flag won't be cleared.

  • In Kinetis Family, some flags need to be written by '1' in order to clear them, in this case, you need to modify the MKE02Zx.h file and add the _IO feature in the SPI_S register:SPI_S register KE02Z.jpg

This way you will be able to write to this register and clear the flag:

if (SPI0->S & SPI_S_SPMF_MASK)
{
    SPI0->S |= SPI_S_SPMF_MASK;
}

I hope this can help you!

Have a nice day!

Regards,

Isaac

View solution in original post

0 Kudos
3 Replies
619 Views
isaacavila
NXP Employee
NXP Employee

Hello Roberto,

  • In order to clear SPIx_S[MODF] flag you need to write any value that you want to SPIx_C1 register, I would suggest to set the SPIx_C1[MSTR] bit due when MODF bit is set, SPI module is configured as slave and MSTR value is cleared, so you can enable this bit again:
if (SPI0->S & SPI_S_MODF_MASK)
{    
    uint8_t temp = SPI0->C1 | SPI_C1_MSTR_MASK;
    SPI0->C1 =  temp;
}‍‍‍‍‍

Or simply:

if (SPI0->S & SPI_S_MODF_MASK)
{
    SPI0->C1 |= SPI_C1_MSTR_MASK;
}

Remember that in order to clear this flag, MODF condition must be removed (SS input should detect a high level voltage), otherwise, this MODF flag won't be cleared.

  • In Kinetis Family, some flags need to be written by '1' in order to clear them, in this case, you need to modify the MKE02Zx.h file and add the _IO feature in the SPI_S register:SPI_S register KE02Z.jpg

This way you will be able to write to this register and clear the flag:

if (SPI0->S & SPI_S_SPMF_MASK)
{
    SPI0->S |= SPI_S_SPMF_MASK;
}

I hope this can help you!

Have a nice day!

Regards,

Isaac

0 Kudos
618 Views
RobertoPaolinel
Contributor II

Hi Isaac,

thanks a lot.

First issue is OK.

About second one: from SW point of view declaring __IO instead of __I will solve.

But from MCU side, its reference manual is reporting that SPI0_S is read only. Sometimes I used to read w1c (write 1 clear): is it just a documentation issue?

Thank you very much

Best Regards

Roberto

618 Views
isaacavila
NXP Employee
NXP Employee

Hello Roberto,

It seems to me that this is a documentation error and I need to validate it with Documentation team. Because when I modified the const modifier in the header file, flag could be cleared correctly.

I hope this help

Regards,
Isaac

0 Kudos