cancel
Showing results for 
Search instead for 
Did you mean: 

TIMERS SYNCHRONIZATION DOES NOT WORK

zohbou
Associate

hello everyone 
im working with stm32f4 nucloe board , i want to implement one wire communication to send data to a microphone but also i need a clock above 40khz to send this data for that im using two timer in master slave mode , one for generating the clock and one for one wire communication , for the one wire communication im creating a delay with the slave timer and set/reset the gpio pin , the weird thing is when the clock of master is above 2khz the one wire communication doesn't work  i dont know what it happen i dont if someone can guide trough this thanks 

 

int main(void)

{

/* USER CODE BEGIN 1 */

HAL_TIM_Base_Start(&htim1);

char spi_buf[SAMPLES];

 

 

 

 

/* USER CODE END 1 */

 

/* MCU Configuration--------------------------------------------------------*/

 

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();

 

/* USER CODE BEGIN Init */

 

/* USER CODE END Init */

 

/* Configure the system clock */

SystemClock_Config();

 

/* USER CODE BEGIN SysInit */

 

/* USER CODE END SysInit */

 

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_USB_DEVICE_Init();

MX_CRC_Init();

MX_TIM1_Init();

MX_TIM8_Init();

MX_TIM2_Init();

/* USER CODE BEGIN 2 */

TimerDelay_Init();

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1);

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

 

 

 

 

//HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);

 

 

 

/* USER CODE END 2 */

 

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

// Start the I2S DMA receive

// HAL_I2S_Receive_DMA(&hi2s1, (uint16_t *)spi_buf, SAMPLES);

 

// Wait for the DMA receive to complete

 

// Now, you can transmit data

sapce();

transmit_start_pilot();

sapce();

// Transmit data bits

for (int i = 0; i < sizeof(sequence) / sizeof(sequence[0]); i++) {

onewire_write_bit(sequence[i]);

}

sapce();

// Transmit stop signal

transmit_stop();

}

0 REPLIES 0