Notes of testing Anybus CompactCom 40 through Raspberry Pi platform in SPI mode

22 Nov 2024

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.