Skip to main content
Graduate
June 26, 2025
Solved

AIS2120SX sensor read data issue

  • June 26, 2025
  • 12 replies
  • 1351 views

Hi , i am trying to read the sensor data of AIS2120x only for sensor ID type , i can see from the bus the data is transferred correctly, but i don't receive any data back from sensor rather its only 0.

i have attached the code snippet for this test, any leads will be helpful. 

@JHo.1 and @Eleon BORLINI @CJeff.1 

 

test 1:
CS_low();
Sensor_Write(0xD1,0x80,ubAisSensor ); // command to read address 0x0C/REG_ID_SENSOR_TYPE from AIS2120x
// according to 32 byte cmmand format 
Sensor_Write(0x00,ubCrcVal,ubAisSensor ); 
CS_high();
 
Test 2:
CS_low();
Sensor_Write(0x8C,0x00,ubAisSensor ); // command to read address 0x0C/REG_ID_SENSOR_TYPE from AIS2120x
set_high();

//Sensor interface 

void Sensor_Write(uint8 addr, uint8 Data,(uint8 Sensor) {
 // application specific
spi_Write(addr);
delay();
spi_Write(Data);
}

//receive ISR
uint8 ubSpiStatus;
uint8 RxData;
_INTERRUPT_VOID SPI_vRxISR (void)
{
if(SPIS==0xA0)
{
RxData = SPID;
ubSpiStatus = 1;
}

}
spi_Write(uint8 addr, uint8 Data,uint8 ubAisSensor)
{
while (!(SPIS)); // Wait until transmit buffer is empty
SPID = data;

while(!ubSpiStatus);
ubSpiStatus = 0;

while (!(SPIS)); // Wait until transmit buffer is empty
SPID = data;

while(!ubSpiStatus);
ubSpiStatus = 0;
appl(RxData); //evaluate data
}

i use nxp 8 bit mcu : MC9S08SH32

MCU is 5v output, level shifter used between MCU and sensor to downgrade voltage to 3V3 ,

 

    This topic has been closed for replies.
    Best answer by anandhram1988

    Its worked now(change is downscaled the spi clock to 500K), thanks all for the reply, but still i am not sure why the clock frequency must be less than 1Mhz even datasheet says 5Mhz.

    12 replies

    anandhram1988AuthorAnswer
    Graduate
    June 27, 2025

    Its worked now(change is downscaled the spi clock to 500K), thanks all for the reply, but still i am not sure why the clock frequency must be less than 1Mhz even datasheet says 5Mhz.

    Super User
    June 27, 2025