Page 1 of 1

reading device ID from MCP251863 Click

Posted: 07 Dec 2022 03:25
by crane
Hello,

I am using MCP251863 Click and designed the SPI interface to read the device ID. I followed the spec to send the data to read (with 4-bit op code + 12-bit address), but receive all 0. The data on SIMO line is correct on the scope, CS and clock are also correct, but the SOMI line stays low. If a pull-up resistor is connected to SOMI line, then the line stays high.

I downloaded and looked at the library at this link https://libstock.mikroe.com/projects/vi ... 1863-click and find the example is not a complete project.
For example, the function spi_master_write_then_read() and spi_master_write() used in the below functions are not in the project source file. I understand they might be architecture dependent. I am wondering what to check next to find out the cause and solution.

Thanks for any advices!
Crane

err_t mcp251863_read_byte ( mcp251863_t *ctx, uint16_t address, uint8_t *data_out )
{
err_t error_flag;

spi_transmit_buffer[ 0 ] = ( uint8_t ) ( ( MCP251863_INS_READ << 4 ) + ( ( address >> 8 ) & 0xF ) );
spi_transmit_buffer[ 1 ] = ( uint8_t ) ( address & 0xFF );

spi_master_select_device( ctx->chip_select );
error_flag = spi_master_write_then_read( &ctx->spi, spi_transmit_buffer, 2, spi_receive_buffer, 1 );
spi_master_deselect_device( ctx->chip_select );

*data_out = spi_receive_buffer[ 0 ];

return error_flag;
}

err_t mcp251863_write_byte ( mcp251863_t *ctx, uint16_t address, uint8_t data_in )
{
err_t error_flag;

spi_transmit_buffer[ 0 ] = ( uint8_t ) ( ( MCP251863_INS_WRITE << 4 ) + ( ( address >> 8 ) & 0xF ) );
spi_transmit_buffer[ 1 ] = ( uint8_t ) ( address & 0xFF );
spi_transmit_buffer[ 2 ] = data_in;

spi_master_select_device( ctx->chip_select );
error_flag = spi_master_write( &ctx->spi, spi_transmit_buffer, 3 );
spi_master_deselect_device( ctx->chip_select );

return error_flag;
}

Re: reading device ID from MCP251863 Click

Posted: 08 Dec 2022 14:21
by IvanJeremic
Hi,

You can see the entire source by using Necto Studio.
https://www.mikroe.com/necto

Select the function you want to see the source of and click the F2 key.

Necto Studio is free as long as you are not using it for commercial purposes.

Regards,

Ivan.

Re: reading device ID from MCP251863 Click

Posted: 08 Dec 2022 19:42
by crane
Thanks Ivan for your reply.
Before I was not sure if the data are sent out correctly. Now is confirmed by decoding the signal. But no response is received from the device. Receives all 0 and the SOMI line stays low.
Is there any way to find the support on this issue?
Thanks!
Crane

Re: reading device ID from MCP251863 Click

Posted: 09 Dec 2022 02:11
by crane
Thanks Ivan for your reply.

I am able to send out the data now. And the scope is able to decode the signal and they are sent out correctly.
But just didn't receive any response from the slave and the line SOMI stays low.

Any advice on where to get support in this case?
Thanks!
Crane

Re: reading device ID from MCP251863 Click

Posted: 09 Dec 2022 15:54
by IvanJeremic
Hi,

Did you comment out the line of code from the picture below for the receiver?
Untitled.png
Untitled.png (4.83 KiB) Viewed 1277 times
Also what development board and MCU are you using?

Regards,

Ivan.

Re: reading device ID from MCP251863 Click

Posted: 09 Dec 2022 20:47
by crane
This issues is addressed. The mode should be set 0, 1 on my MCU, not 0, 0, or 1, 1 that are specified by the device.

Thanks!
Crane