SPI PT60

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决
1,057 次查看
eliezeroc
Contributor III

Hello guys, I'm having problems with the CPI EN 60.

Below my boot code, reading and writing.

Also follows signal aspect I need to generate.

Thanks,

 

how to get my signal.

132984_132984.PNGhow to get my signal.PNG

 

like this my sign.

132985_132985.PNGmy signal.PNG

 

 

void SPI0_Init( void )

{

  volatile char dummy;

  SYS_SOPT1_SPI0PS  = 1;       

  SPI0_C1_MSTR = 1;        

  SPI0_C1_CPHA = 0;      

  SPI0_C2_MODFEN = 1;

  SPI0_C1_SSOE = 1;

  SPI0_BR = 0x73;

  dummy = SPI0_D;

  SPI0_C1_SPE  = 1;        

}

 

void Wr(unsigned char Address, unsigned char value)

{  

   SPI0_S |= SPI0_S_SPTEF_MASK;  

   SPI0_D = ( (Address<<1)&0x7E);

   while( !SPI0_S_SPRF );

  

   SPI0_S |= SPI0_S_SPTEF_MASK;  

   SPI0_D = value;  

   while( !SPI0_S_SPRF ); 

}

 

 

unsigned char Rd(unsigned char Address) 

{  

   unsigned char value,limpa;         

   SPI0_S |= SPI0_S_SPTEF_MASK;  

   SPI0_D = ((Address<<1)&0x7E)| 0x80;     

   limpa=SPI0_D;

   while(!SPI0_S_SPRF);

   value = SPI0_D;   

   return value;

}

标签 (1)
标记 (2)
1 解答
894 次查看
Stano
NXP Employee
NXP Employee

Hello Eliezer,

The 16-bit SPI module is SPI1. So you need to use SPI1_C2_SPIMODE as defined in the header file:

#define SPI1_C2_SPIMODE                 _SPI1_C2.Bits.SPIMODE.

The disable the SSOE pin is not right way to receive 16-bit data. The SPI1 module controls properly the SS pin also.

Best Regards,

Stano.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
894 次查看
Stano
NXP Employee
NXP Employee

Hello Eliezer,

your code is OK, but it is set for 8-bit mode os SPI module. If I understand well, you want to use 16-bit mode like on picture_1, instead of 8-bit mode on picture_2.

You need set SPIMODE bit in the SPIx_C2 register to use 16-bit mode. Then the 16-bit value will be send/received from/to SPI module.

Best Regards,

Stano.

894 次查看
eliezeroc
Contributor III

Stano Hello, thank you for your attention.

I'm using the SPI0, and when I set the SPI0_C2_SPIMODE = 1, the error occurs: C1815 SPI0_C2_SPIMODE not declared (or typename).

It is only SPI1 can be configured to 16b?

0 项奖励
回复
894 次查看
kef2
Senior Contributor V

Yes, according to S08PT block diagram, SPI0 is 8-bit module and SPI1 is 16-bit module.

You can disable SPI0_C1_SSOE and toggle chip select pin from software and do two 8bit transfers (address + data) both when writing to device and reading from device.

Regards,

Edward

895 次查看
Stano
NXP Employee
NXP Employee

Hello Eliezer,

The 16-bit SPI module is SPI1. So you need to use SPI1_C2_SPIMODE as defined in the header file:

#define SPI1_C2_SPIMODE                 _SPI1_C2.Bits.SPIMODE.

The disable the SSOE pin is not right way to receive 16-bit data. The SPI1 module controls properly the SS pin also.

Best Regards,

Stano.

0 项奖励
回复