Let see how Logic Analyzer catches the digital output pulse generated by STM32F411VET board.
1. Generate Digital Pulse project
1.1. Create new project
- Based on GPIO LED blinking control project, we can generate a simple digital pulse output by toggle output data from PDO pin.
- Create a new project similar to GPIO LED project. You can copy GPIO_HAL project to other place and change project name.
1.2. Modify source
- In main.c file of GPIO_HAL project, add define for PULSE_PIN;
/* Define Pulse pin */ #define PULSE_PIN (1<<0)
- In LED_Init() function, add code to init PULSE_PIN:
/* Configure the GPIO_LED pin adn PULSE_PIN as output mode, pullup option and speed fast */ GPIO_InitStruct.Pin = LED0_PIN | LED1_PIN | LED2_PIN | LED3_PIN | PULSE_PIN;
- Add code to toggle output PD0 pin in super loop:
while(1) { /* Toggle LED2_PIN */ HAL_GPIO_TogglePin(LED_PORT, LED2_PIN); /* Toggle PULSE_PIN */ HAL_GPIO_TogglePin(LED_PORT, PULSE_PIN); /* Delay 1000 ms */ HAL_Delay(1000); }
- Rebuild and flash image into board, press reset button to see LED2 is blinking
- Now we generated a pulse from PD0 pin:
- 50% duty cycle
- T period time is 2s
- We will use Logic Analyzer to capture output and see it matches our expectation or not.
2. Connect hardware device
- Connect PD0 pin from STM32F411E DISCOVERY board to CH1 of Logic Analyzer
3. Use logic analyzer to verify signal
- Run Logic Analyzer application of PC
- Config capture speed 2MS/s and time is 20s
- Choose 1-Wire protocol
- Run the box to see LED blinking, that means we are generating the pulse from PD0
- Click start button to start capturing pulse
- And you can see the pulse result when zooming out
- As you can see in result picture, the Width is 0.9973s and period T is 1.995s. It is very close to our expected result, and that means we captured the digital signal successfully by using Logic Analyzer
4. Logic Analyzer applicability
You can see the long protocol list that supported by logic analyzer. It doesn’t only capture the digital signal for you but also help you to analyze the data based on the protocol, then you can debug almost transfer issue by using it.
From now on, whenever working with protocols, I will show you the way to debug data by using this powerful tool.
Hope you enjoy.