MR-CANHUBK344 SPI

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
436件の閲覧回数
ankitv
Contributor II

Hi, 

I want to send 16-bit data on SPI. Getting the following error:

"Data type mismatch. 'Input Port 1' of 'mrcanhubk344_dio_s32ct/Triggered Subsystem/Spi' expects a signal of data type 'uint8'. However, it is driven by a signal of data type 'uint16'"

avi_magna_0-1701968876443.png

 

Where can I change the data type to uint16 ?

I am using the channel 0 on P1A connector

avi_magna_1-1701969097981.png

Peripherals settings are as follows, I have updated the SpiDataWidth to 16. 

avi_magna_2-1701969135809.png

Thanks

 

 

 

 

0 件の賞賛
1 解決策
371件の閲覧回数
robertv
NXP Employee
NXP Employee

Hello @ankitv ,

Regarding the question about using SPI in the P1A connector, that involves configuring the pins for the SPI1 instance.

robertv_0-1702467122570.png

 

Afterwards, the SPI1 instance has to be configured for the desired functionality in the SpiPhyUnit tab inside the SpiGeneral tab. This involves choosing the SPI instance, SpiPhyUnitMapping and SpiPhyUnitMode.

As for the other question, the SPI driver expects uint8 data as input. So, when sending data, it has to be broken into uint8 values. To be able to send multiple uint8 values, you will have to use a Data Store Memory, configured as an array of uint8 values.

robertv_1-1702467155073.png

Choosing the type of buffer being used also has an influence on the SPI transfer.
When using the internal buffer, the user has to configure the number of buffers utilized when sending data, by modifying the SpiIbNBuffers field.
When using an external buffer, this is no longer an issue. On the other hand, the user can choose the maximum number of buffers that can be used - by default it's set to 1000.

So, in your case, I would suggest using the external buffer, chosen by selecting the "EB" option for the SpiChannelType field, along with the Spi_SetupEB function of the Spi block, to be able to store data in the buffer.

The SpiDataWidth option being set to 16 still involves using uint8 variables as inputs. One aspect that should be taken into consideration is how the data is ordered afterwards.
Sending the following array, [1 2 3 4] would show up as [2 1 | 4 3] on the analyzer. Two 16-bit frames, each made up of two 8-bit values which end up reversed because of the order of the transmission.
Setting SpiDataWidth to 8 and sending the same array would show up as [ 1 | 2 | 3 | 4]. Four 8-bit frames, each made up of its own 8 bit value.

Regards,
Robert V

元の投稿で解決策を見る

0 件の賞賛
1 返信
372件の閲覧回数
robertv
NXP Employee
NXP Employee

Hello @ankitv ,

Regarding the question about using SPI in the P1A connector, that involves configuring the pins for the SPI1 instance.

robertv_0-1702467122570.png

 

Afterwards, the SPI1 instance has to be configured for the desired functionality in the SpiPhyUnit tab inside the SpiGeneral tab. This involves choosing the SPI instance, SpiPhyUnitMapping and SpiPhyUnitMode.

As for the other question, the SPI driver expects uint8 data as input. So, when sending data, it has to be broken into uint8 values. To be able to send multiple uint8 values, you will have to use a Data Store Memory, configured as an array of uint8 values.

robertv_1-1702467155073.png

Choosing the type of buffer being used also has an influence on the SPI transfer.
When using the internal buffer, the user has to configure the number of buffers utilized when sending data, by modifying the SpiIbNBuffers field.
When using an external buffer, this is no longer an issue. On the other hand, the user can choose the maximum number of buffers that can be used - by default it's set to 1000.

So, in your case, I would suggest using the external buffer, chosen by selecting the "EB" option for the SpiChannelType field, along with the Spi_SetupEB function of the Spi block, to be able to store data in the buffer.

The SpiDataWidth option being set to 16 still involves using uint8 variables as inputs. One aspect that should be taken into consideration is how the data is ordered afterwards.
Sending the following array, [1 2 3 4] would show up as [2 1 | 4 3] on the analyzer. Two 16-bit frames, each made up of two 8-bit values which end up reversed because of the order of the transmission.
Setting SpiDataWidth to 8 and sending the same array would show up as [ 1 | 2 | 3 | 4]. Four 8-bit frames, each made up of its own 8 bit value.

Regards,
Robert V

0 件の賞賛