DACA_Buf = DAC_A_Write << 12 | 100*Wave_LUT[z];
if (MDepth == 33){
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim == &htim6 )
{
Divison_Table[z] = round((102.4-(102.4*0.33)) + (0.33*(Wave_LUT[z]/(1575/102.4)))); // 15.4 is calculated with 1575 divide by D value. Vout=Vsupply*(D/4095)
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_RESET);
DACA_Buf = DAC_A_Write << 12 | Divison_Table[z];
HAL_SPI_Transmit(&hspi2,(uint8_t*)&DACA_Buf,2,100);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_RESET);
DACB_Buf = DAC_B_Write << 12 | Divison_Table[z];
HAL_SPI_Transmit(&hspi2,(uint8_t*)&DACB_Buf,2,100);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_SET);
z++;
if (z>=127)z=0;
}
}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
if (htim == &htim6 )
{
TIM_Flag=1;
}
}
while(1)
...
else if (MSet == 1){
if (TIM_Flag ==1){
if (MDepth == 33)
{
Divison_Table[z] = round((102.4-(102.4*0.33)) + (0.33*(Wave_LUT[z]/(1575/102.4)))); // 15.4 is calculated with 1575 divide by D value. Vout=Vsupply*(D/4095)
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_RESET);
DACA_Buf = DAC_A_Write << 12 | Divison_Table[z];
HAL_SPI_Transmit(&hspi2,(uint8_t*)&DACA_Buf,2,100);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_RESET);
DACB_Buf = DAC_B_Write << 12 | Divison_Table[z];
HAL_SPI_Transmit(&hspi2,(uint8_t*)&DACB_Buf,2,100);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_SET);
z++;
if (z>=127)z=0;
}
...what about a static variable counting 0-1-0-1-0-1-0....How can I implement this, "Another approach is to run the ISR twice as often. One time one channel, next time other channel"?
function xx
{
static uint8_t channel
if (channel == 1)
{
update DAC_channel1
channel = 0
}
else
{
update DAC_channel0
channel = 1
}
}//end of function
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?