Read parallel data that is valid in every falling edge clock nucleo-h743ZI2
Hello
I have an external adc with 2 parallel output pins each is 1 bit (2 bits) total, with clK_out pin, I am trying to read the parallel pins using nucleo-h743ZI2 (480Mhz), I followed [AN4666] example to receive the data1, clk_out is connected to PA6 which is defined as a TIMER in input capture and it triggers the DMA to GPIO pins and save it into memory. Unfortunately my code read the pins only once and I was expecting that it would read every falling edge of the clk_out. all I trying to do is make the dma read every falling edge. here is my code I would really appreciate all the help I can get.
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define MAX_FRAME_SIZE 100
#define BUFFER_SIZE 20
#define HALF_BUFFER_SIZE BUFFER_SIZE/2
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
volatile int LastITHalfComplete = 0;
volatile int32_t FullDataIndex = 0;
volatile int i = 0;
volatile uint8_t transferComplete = 0;
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
TIM_HandleTypeDef htim1;
DMA_HandleTypeDef hdma_tim1_ch1;
UART_HandleTypeDef huart3;
PCD_HandleTypeDef hpcd_USB_OTG_FS;
/* USER CODE BEGIN PV */
static uint8_t aFull_Buffer[MAX_FRAME_SIZE] = {0};
static uint8_t aDST_Buffer[BUFFER_SIZE] = {0};
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART3_UART_Init(void);
static void MX_USB_OTG_FS_PCD_Init(void);
static void MX_TIM1_Init(void);
static void MX_DMA_Init(void);
/* USER CODE BEGIN PFP */
static void TransferComplete(DMA_HandleTypeDef *hdma_tim1_ch1);
static void TransferError(DMA_HandleTypeDef *hdma_tim1_ch1);
static void HalfTransferComplete(DMA_HandleTypeDef *hdma_tim1_ch1);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* 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_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init();
MX_TIM1_Init();
MX_DMA_Init();
/* USER CODE BEGIN 2 */
// Attach DMA callback functions
htim1.hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = HalfTransferComplete;
htim1.hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TransferComplete;
htim1.hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TransferError;
// Start DMA in interrupt mode, specify source and destination
HAL_DMA_Start_IT(htim1.hdma[TIM_DMA_ID_CC1], (uint32_t) &GPIOC->IDR, (uint32_t) &aDST_Buffer, 1);
// Enable timer to trigger DMA transfer - CC1DE bit
__HAL_TIM_ENABLE_DMA(&htim1, TIM_DMA_CC1);
// Enable timer input capture
HAL_TIM_IC_Start(&htim1, TIM_CHANNEL_1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
/* USER CODE BEGIN WHILE */
while (1) {
//if (transferComplete) {
//transferComplete = 0;
// Transmit buffer to UART
// Prepare data into buffer
//HAL_UART_Transmit_IT(&huart3, buff, LEN);
//}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}the interrupts
static void HalfTransferComplete(DMA_HandleTypeDef *hdma_tim1_ch1) {
int position = 0;
LastITHalfComplete = 1;
/*Copy the first part of the received buffer */
for (int i = 0; i < HALF_BUFFER_SIZE; i++)
{
aFull_Buffer[FullDataIndex] = aDST_Buffer[i+position];
FullDataIndex++;
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_1);
}
}
static void TransferComplete(DMA_HandleTypeDef *hdma_tim1_ch1) {
int position = HALF_BUFFER_SIZE;
LastITHalfComplete = 0;
/* Copy the second part of the received buffer */
for (int i = 0; i < HALF_BUFFER_SIZE; i++)
{
aFull_Buffer[FullDataIndex] = aDST_Buffer[i+position];
FullDataIndex++;
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
}
transferComplete = 1;
}
static void TransferError(DMA_HandleTypeDef *hdma_tim1_ch1) {
HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_14);
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart3) {
// Enable again DMA for a new transfer
HAL_DMA_Start_IT(htim1.hdma[TIM_DMA_ID_CC1], (uint32_t) &GPIOC->IDR, (uint32_t) aDST_Buffer, BUFFER_SIZE);
}Thank you in advance
