Skip to content

Conversation

@JaydenWong27
Copy link

Completed embedded firmware bootcamp

{
uint8_t tx[2];
uint8_t rx[2];
uint16_t adc_value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you meant to allocate 2 bytes?


HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);

HAL_SPI_TransmitReceive(&hspi1, tx, rx, 2, HAL_MAX_DELAY);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you meant to only transmit/receive for 2 bytes? The diagram in 6.1 of the adc datasheet seems to disagree


HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);

adc_value = ((rx[0] & 0x03) << 8) | rx[1];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might need to adjust this later or not :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants