This article introduces some notes of testing Anybus CompactCom 40 through Raspberry Pi platform in SPI mode.
APPLICABLE PRODUCTS
Anybus CompactCom 40
QUESTION
- The Notes of testing Anybus CompactCom 40 through Raspberry Pi platform in SPI mode.
ANSWER
- If Anybus CompactCom 40 module connect Raspberry Pi through fly wire like the picture as follow , should to reduce speed of SPI.
-
-
Adjust BCM2835_SPI_CLOCK_DIVIDER_128 in /abcc_adapt/abcc_sys_adapt.c to reduce speed of SPI interface
-
#if( ABCC_CFG_DRV_SPI )
case ABP_OP_MODE_SPI:
/*
** Check if running as root
*/
if( geteuid() != 0 )
{
fprintf( stderr, "WARNING! To use SPI as communication interface, this program must be run as root!\n\n" );
return( FALSE );
}
if( !bcm2835_spi_begin() )
{
ABCC_PORT_DebugPrint( ( "SPI initialization failed!\n" ) );
return( FALSE );
}
else
{
bcm2835_spi_setBitOrder( BCM2835_SPI_BIT_ORDER_MSBFIRST );
bcm2835_spi_setDataMode( BCM2835_SPI_MODE0 );
bcm2835_spi_setClockDivider( BCM2835_SPI_CLOCK_DIVIDER_128 ); /* */
bcm2835_spi_chipSelect( BCM2835_SPI_CS0 );
bcm2835_spi_setChipSelectPolarity( BCM2835_SPI_CS0, LOW );
}
break;
#endif
-
-
- To use the SPI interface it must be enabled via the Raspberry Pi Configuration tool.
-
sudo raspi-config
-
Check SPI device description file in Raspberry Pi to ensure SPI enabled
-
$ ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1
-
-
Install BCM28335 library
- bcm2835: C library for Broadcom BCM 2835 as used in Raspberry Pi
- Note: the host application of version later than 3.11 is no longer need BCM28335 library.
-
sudo raspi-config