KE02 SPI Documentation

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

KE02 SPI Documentation

ソリューションへジャンプ
1,133件の閲覧回数
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

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
947件の閲覧回数
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 件の賞賛
返信
3 返答(返信)
948件の閲覧回数
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 件の賞賛
返信
947件の閲覧回数
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

947件の閲覧回数
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 件の賞賛
返信