reading device ID from MCP251863 Click

Discussion on projects that are created by users and posted on mikroElektronika website.
Post Reply
Author
Message
crane
Posts: 4
Joined: 07 Dec 2022 03:06

reading device ID from MCP251863 Click

#1 Post by crane » 07 Dec 2022 03:25

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;
}

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: reading device ID from MCP251863 Click

#2 Post by IvanJeremic » 08 Dec 2022 14:21

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.

crane
Posts: 4
Joined: 07 Dec 2022 03:06

Re: reading device ID from MCP251863 Click

#3 Post by crane » 08 Dec 2022 19:42

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

crane
Posts: 4
Joined: 07 Dec 2022 03:06

Re: reading device ID from MCP251863 Click

#4 Post by crane » 09 Dec 2022 02:11

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

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: reading device ID from MCP251863 Click

#5 Post by IvanJeremic » 09 Dec 2022 15:54

Hi,

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

Regards,

Ivan.

crane
Posts: 4
Joined: 07 Dec 2022 03:06

Re: reading device ID from MCP251863 Click

#6 Post by crane » 09 Dec 2022 20:47

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

Post Reply

Return to “User Projects”