Post Go back to editing

How to use EVAL-CN0428 by I2C with a generic microcontroller?

Hi to everyone here
please,I'm in urgent need to use the capabilities of the EVAL-CN0428,in conjunction with an existing microcontrollor board,connected with an EVAL-M355-ARDZ-INT board.


My question is:
Is there a guide about how to use CN0428 with a generic microcontroller?


I have the ADICUP3029 code,ADICUP3029 board and CN0428 code and board.
Despite this, I'm not able to reply on my microcontroller the communication necessary to have PH,conductivity and temperature measurements.
On my board an I2C port and some GPIO's are available
By now I need only 1 CN0428,so there is no need of I2C address reassignement.
I have experienced communication,but  without properly understanding details.

I have found some unexpected behaviour:
1)The CN0428,by default ,acknowledges the I2C address 0x98
Changing its address with command 0x80 it still acknowledges the I2C address 0x98,is it correct?
I kept low the CS pin during this operation,and I waited for 1 second,as in the ADICUP3029 example:
this is my code about it

    SS1_LOW;
	Delay(100);
	i2c_write_data_buffer[0]=SET_I2C_ADDRESS;
	i2c_write_data_buffer[1]=new_addr;  
	hal_st=HAL_I2C_Master_Transmit(&hi2c1,old_addr, i2c_write_data_buffer, 2, 50);
	Delay(1000); /* wait for selected slave to change its address */
	SS1_HIGH;

2)Lot of communication between boards is done sending ASCII values on I2C,for example ,when requesting measuresensor by PuTTY terminal , a string is sent by ADICUP3029
to CN0428 :   cmeasuresensor\r   ,then other strings are read by I2C reads from CN0428,they look the same of  strings printed on PuTTY terminal.
I am not able to relate these strings with I2C commands listed in adi_m355_gas_sensor.h

3)Still about strings,i'm able to read back in some way the welcome message:Welcome to Water Quality Demo!Sensor Site: 1!  ..but I wonder how it works:
If I read the I2C buffer more than necessary CN0428 pulls down(stretches?) the SCL pin,and it remains low unless I reset the CN0428,so, what tells to I2C master how long is the message to be read?

4)It looks that long delays are necessary between reset and some operations,is there a list of these timings?I mean without searching them one by one in ADICUP3029 CN0428 example code?
Actually the code is small ,but I would like to be shure to respect all the timings and dont miss anyone.

Thanks for your help or your attention.

Diego Colombo
Milan,Italy.









Noticed some errors in caps,and other errors
[edited by: Diegotrex at 8:35 AM (GMT -5) on 18 Nov 2021]
Parents
  • Hi Diego, we're looking into this and will reply shortly.

    -Mark

  • Thanks Mark
    I checked some Q&A in the forum before sending my message,but Ii missed this one.
    CN0428 default firmware communication protocol - Q&A - Reference Circuits - EngineerZone (analog.com)
    I read it only after posting and before your answer.
    That answers to one of the questions, and contains fundamental infos:

    In fact analyzing the code and the answer it looks there is a kind of polling,
    command 'a'=0x61 is sent(I call it command but maybe is better
    consider it a register address?)
    then a 'c'=0x63  is issued followed by read of the proper amount of data,
    this looks compliant to the code in cn0428_cn0429.cpp rows from 1241 to 1255

    	do { /* 0.1s loop waiting for slave */
    		delay_ms(95);
    		numbytes = 0;
    		pGasSensor->I2CReadWrite(READ,
    					 BYTES_TO_READ,
    					 (uint8_t *) &numbytes,
    					 1);
    		delay_ms(5);
    
    		/* read <=255B chunks until slave buffer is empty */
    		while (numbytes > 0) { /* data available */
    			tempError = pGasSensor->I2CReadWrite(READ,
    							     0x63,
    							     &Slave_Rx_Buffer[0],
    							     numbytes);


    Hoping that is useful to the discussion and other readers of this forum:
    20 or 0x14 should be the device address assigned to my CN0428 board.
    Is it correct?

    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    22' + NAK Yes,22 chars
    Setup Write to ['20']
    c
    Count of chars Setup Read to ['21']
    1 T
    2 e
    3 m
    4 p
    5 e
    6 r
    7 a
    8 t
    9 u
    10 r
    11 e
    12 :
    13 '
    14 0
    15 8
    16 4
    17 .
    18 3
    19 5
    20 1
    21 \r
    22 \n + NAK
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    16' + NAK Yes,16 chars
    Setup Write to ['20']
    c
    Count of chars Setup Read to ['21']
    1 p
    2 H
    3 :
    4 '
    5 1
    6 3
    7 .
    8 2
    9 4
    10 3
    11 5
    12 \r
    13 \n
    14 \r
    15 \n
    16 ~ + NAK
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK


    Thanks

Reply
  • Thanks Mark
    I checked some Q&A in the forum before sending my message,but Ii missed this one.
    CN0428 default firmware communication protocol - Q&A - Reference Circuits - EngineerZone (analog.com)
    I read it only after posting and before your answer.
    That answers to one of the questions, and contains fundamental infos:

    In fact analyzing the code and the answer it looks there is a kind of polling,
    command 'a'=0x61 is sent(I call it command but maybe is better
    consider it a register address?)
    then a 'c'=0x63  is issued followed by read of the proper amount of data,
    this looks compliant to the code in cn0428_cn0429.cpp rows from 1241 to 1255

    	do { /* 0.1s loop waiting for slave */
    		delay_ms(95);
    		numbytes = 0;
    		pGasSensor->I2CReadWrite(READ,
    					 BYTES_TO_READ,
    					 (uint8_t *) &numbytes,
    					 1);
    		delay_ms(5);
    
    		/* read <=255B chunks until slave buffer is empty */
    		while (numbytes > 0) { /* data available */
    			tempError = pGasSensor->I2CReadWrite(READ,
    							     0x63,
    							     &Slave_Rx_Buffer[0],
    							     numbytes);


    Hoping that is useful to the discussion and other readers of this forum:
    20 or 0x14 should be the device address assigned to my CN0428 board.
    Is it correct?

    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    22' + NAK Yes,22 chars
    Setup Write to ['20']
    c
    Count of chars Setup Read to ['21']
    1 T
    2 e
    3 m
    4 p
    5 e
    6 r
    7 a
    8 t
    9 u
    10 r
    11 e
    12 :
    13 '
    14 0
    15 8
    16 4
    17 .
    18 3
    19 5
    20 1
    21 \r
    22 \n + NAK
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    16' + NAK Yes,16 chars
    Setup Write to ['20']
    c
    Count of chars Setup Read to ['21']
    1 p
    2 H
    3 :
    4 '
    5 1
    6 3
    7 .
    8 2
    9 4
    10 3
    11 5
    12 \r
    13 \n
    14 \r
    15 \n
    16 ~ + NAK
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK


    Thanks

Children