Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The SPI communication will need to be further configured. To configure it go to the .ioc file, find SPI1 in the Connectivity menu on the left:

...

The data size is the length of each message in bits, to make communication easier, set this to 8 bits.In the ADC datasheet there is information on controlling the ADC from the microcontroller in Sections Then, configure the parameters:

  • Data Size

  • First Bit

  • Clock Polarity

  • Clock Phase

To do so, do the following:

  1. Understand what each parameter does/means

  2. Look in the ADC datasheet under sections 5.0 and 6.1

...

Specifically check the following configuration parameters:

  • Clock polarity

  • If the ADC sends Most or Least significant bit first (MSB/LSB)

...

  1. to learn how the ADC communicates

  2. Draw conclusions and set appropriate values

Also, it is good to note that the MCU can run much faster than the ADC , so adding a prescaler and outpace it. Add a Prescaler of 16 or greater in the configuration of SPI1 will reduce the speed it needs to operate atto keep the baud rate reasonable for the ADC.

The Hal library automatically generates the base code required to run the configuration you set when you save the .ioc file. You do want the IDE to generate code for you.

...