AnsweredAssumed Answered

About HAL_UART_Receive_IT arguments

Question asked by mich.lei on Aug 18, 2016
Latest reply on Aug 18, 2016 by Clive One
One slip of my finger and my post was gone. I hope this is not a duplicate post.

I am receiving serial data one byte at a time. For that I need an one byte array, I think. Does it have to be an array? One byte array is not much of  an array. This works:
"volatile uint8_t pufkuri[1];"

How to use something else than an array? I have gotten warnings and latest test gave this:"#142: expression must have pointer-to-object type"

My test program works, so this is not any kind of emergency, but I would like to relearn some C.
            /* Includes ------------------------------------------------------------------*/
            #include "stm32f4xx_hal.h"
 
            /* USER CODE BEGIN Includes */
             #include <stdio.h>
            #include <string.h>
            /* USER CODE END Includes */
 
            /* Private variables ---------------------------------------------------------*/
            ADC_HandleTypeDef hadc1;
 
            UART_HandleTypeDef huart2;
 
            /* USER CODE BEGIN PV */
            /* Private variables ---------------------------------------------------------*/
                    char klaa[40];
volatile uint8_t pufkuri[1];
 
                volatile char isopuf[10];
                    int c,kokon;
                    volatile int maara;
                    double ccc,***;
            /* USER CODE END PV */
 
            /* Private function prototypes -----------------------------------------------*/
            void SystemClock_Config(void);
            void Error_Handler(void);
            static void MX_GPIO_Init(void);
            static void MX_ADC1_Init(void);
            static void MX_USART2_UART_Init(void);
 
            int main(void)
            {
 
                /* MCU Configuration----------------------------------------------------------*/
 
                /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
            HAL_Init();
 
                /* Configure the system clock */
            SystemClock_Config();
 
                /* Initialize all configured peripherals */
            MX_GPIO_Init();
            MX_ADC1_Init();
            MX_USART2_UART_Init();
 
 
 
                /* USER CODE BEGIN 1 */
            maara=0;
            strcpy(klaa, "\0");
            strcpy(klaa, "adcusart16082016");
            c=strlen(klaa);
                            //  strcpy(klaa,b);
            HAL_UART_Transmit(&huart2,(uint8_t *) klaa,c,1000);
            strcpy(klaa, "\0");
            strcpy(klaa, "\n");
 
                c=strlen(klaa);
 
                HAL_UART_Transmit(&huart2,(uint8_t *) klaa,c,1000);
                strcpy(klaa, "\n");
                strcpy(klaa, "\0");
 
                    HAL_UART_Receive_IT(&huart2, (uint8_t *) pufkuri, 1)        ;
                /* USER CODE END 2 */
 
                /* Infinite loop */
                /* USER CODE BEGIN WHILE */
                while (1)
                {
     
                    HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1);
 
                    HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                    HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;                  //4
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                    HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;      //11
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
 
                 HAL_ADC_Start(& hadc1);
                                    while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
                                    {
                                    }
                    ccc= HAL_ADC_GetValue(&hadc1)+ccc;//16
 
 
                    kokon=ccc/16;
 
                    sprintf (klaa,"Readout %d \n", kokon);
                    c=strlen(klaa);
                    HAL_UART_Transmit(&huart2,(uint8_t *) klaa,c,1000);
                    strcpy(klaa, "\0");
                                    if (maara>0)
                                    {
                                        HAL_UART_Transmit(&huart2,(uint8_t *) pufkuri,maara,1000);
                                        maara=0;
                                        strcpy(klaa, " kesk \n");
                                        c=strlen(klaa);
                                        HAL_UART_Transmit(&huart2,(uint8_t *) klaa,c,1000);
                                        HAL_UART_Receive_IT(&huart2, (uint8_t *) pufkuri, 1)        ;
                                    }
                    HAL_Delay(500);
                }
                /* USER CODE END 1 */
 
                /* MCU Configuration----------------------------------------------------------*/
 
                /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 
                /* USER CODE BEGIN 2 */
 
                /* USER CODE END 2 */
 
 
 
                }
 
            void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
                {
                    isopuf[maara]=pufkuri[0];
                    maara++;
                }

Outcomes