0
\$\begingroup\$

I'm currently working on a custom PCB with cc1120 datsheet as transceiver and stm32f446RET6 as MCU. I integrate the cc1120 library from IT's library. The device uses SPI as serial communication. Here is the communication example given in the User’s Guide. enter image description here

With this information I configured the SPI settings as: enter image description here

After that I use HAL_SPI_TransmitRecieve( ) function as my comm func. in driver. But I'm not gonna share the complex library instead I will demonstrate the situation. My CS pin and CC1120 reset pin is logic HIGH in idle by software.

    txdata[0] = 0x30;

    HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, 0);
    HAL_SPI_TransmitReceive(&hspi1, txdata, rxdata, 1, 500);
    HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, 1);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
      txdata[0] = (0x2F | 0x80); //For read operation I'm putting 1 in MSB
      HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, 0);
      HAL_Delay(10);
      HAL_SPI_TransmitReceive(&hspi1, txdata, rxdata, 1, 500);
      HAL_Delay(10);
      txdata[0] = 0x8F;
      HAL_SPI_TransmitReceive(&hspi1, txdata, rxdata, 1, 500);
      HAL_Delay(10);
      txdata[0] = 0x00;
      HAL_SPI_TransmitReceive(&hspi1, txdata, rxdata, 1, 500);
      HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, 1);
      HAL_Delay(10);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

In this code first I use command SRES (0x30) for reset the device. In this situation device must be send chip status from MISO line when I start to transmit from MOSI line. But I can't see the chip status byte in MOSI line (I'm seeing 0xFF as chip status byte). Chip status byte explained in datasheet as: "When the header byte, data byte, or command strobe is sent on the SPI interface, the chip status byte is sent by the CC112X on the SO pin." and: enter image description here

Then in while loop, I want to access PART NUMBER register for read the chip ID. The chip ID reg is a extended register (0x2F8F). So first I'm transmitting 0x2F then 0x8F after that I want to receive chip ID. But again I can't get anything. I can't reach the CC1120 device but I don't know why. I tried several different configurations. I use oscilloscope for see the lines and SCK line looks fine to me. Here is the MCU and the RF part of PCB. Almost same as the reference design of the CC1120: enter image description here

enter image description here So there is a external 32 MHz oscillator indicated as Y2 but we don't have it so we use 32.578 MHz instead. Is that a problem for the device?
I managed to get better scope results:  In while loop firstly I'm sending (0xAF -> 0x2F | 0x80) with 1 in the MSB for read operation (Sending 0x2F first for extended addresses). MOSI and SCK

enter image description here

Then I'm sending 0x8F for register address:

enter image description here

Then I'm sending all zeros for receive the data:

enter image description here

 But again I cannot see anything in MISO line:

enter image description here

How can I solve this problem?

\$\endgroup\$
2
  • \$\begingroup\$ What does "CH2:MOSI In MISO line" means? \$\endgroup\$
    – Rodo
    Commented Apr 24 at 3:21
  • \$\begingroup\$ Thats my bad CH2: MOSI line In MISO line.... \$\endgroup\$ Commented Apr 24 at 9:40

2 Answers 2

0
\$\begingroup\$

You are only ever transferring one byte for each transaction you want to do.

If you want to read or write a register, you need to transfer the operation to read or write and the register address in the first byte, then the transfer of next byte is the parameter or status.

So basically, if you use the HAL provided readwrite, it does exactly what you are asking it to do, transfer one byte out and in, each byte sent out when CS is low. That is not the way the protocol works, like in the pictures you posted.

You need two or more bytes in the same transaction like this:

For write:

  • pull CS low
  • send command/address bytes
  • send data bytes (if any)
  • pull CS high
\$\endgroup\$
1
  • \$\begingroup\$ I tried it but it isn't work. I managed to get better scope results and i will share it \$\endgroup\$ Commented Apr 24 at 9:04
0
\$\begingroup\$

We solved the problem. We were using a 32.768 MHz instead of 32 MHz oscillator. When we soldered 32 MHz, one SO line pulled logic LOW when CS was asserted.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.