2020-05-25 08:52 AM
for exmple, this is a part of the code:
void DAC_AD5621_Write ( uint64_t DAC_Data)
{
HAL_GPIO_WritePin(dac_cs_GPIO_Port, dac_cs_Pin, GPIO_PIN_RESET);////Select SPI
DAC_Data = (DAC_Data&0x0FFF)<<2 ;
uint8_t DAC_Data1= (uint8_t)((DAC_Data>>8)&0x00FF);
uint8_t DAC_Data2= (uint8_t)(DAC_Data&0x00FF);
HAL_SPI_Transmit(&hspi1,DAC_Data1,10,100);
HAL_SPI_Transmit(&hspi1,DAC_Data2,10,100);
HAL_GPIO_WritePin(dac_cs_GPIO_Port, dac_cs_Pin, GPIO_PIN_SET);//Deselect SPI
}
while (1)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,GPIO_PIN_RESET);
delay_1u(10);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,GPIO_PIN_SET);
}
2020-05-25 09:25 AM
Initialize them as GPIO output pins after using them as SPI. If they're still in AF mode, output level will be ignored.
2020-05-25 10:06 AM
You may just be able to change the MODER register to change them from AF (Alternate Function) to input or output mode, using MODIFY_REG(GPIOA->MODER,***,yyy) where *** is a suitable mask to turn those bits off, and yyy are bits to set in the register. Replace GPIOA with the I/O bank you are using - e.g. GPIOA/B/C etc.
2020-05-26 11:40 PM
hi, thank you for help.
can you sharpen the concept "AF mode"?
2020-05-27 04:30 AM
> can you sharpen the concept "AF mode"?
Look up alternate function mode in the reference manual.