2023-06-05 02:29 PM
Hello,
I'm trying to send data over uart from a another file.
My main :
UART_HandleTypeDef huart1;
DMA_HandleTypeDef hdma_usart1_tx;
int main(void)
{
MX_USART1_UART_Init();
While(1)
{
}
}
My error is :
../Core/Src/AT_Command.c:22:21: error: 'huart1' undeclared (first use in this function)
I'have read that a must declare "UART_HandleTypeDef" as extern...
but i'no unsterdant how.
do you have more information ?
Solved! Go to Solution.
2023-06-05 10:51 PM
Declaring it (the global variable) extern is required
because the variable is declared in another file (that can be accessed) in the program.
They are in different scope.
2023-06-05 10:51 PM
Declaring it (the global variable) extern is required
because the variable is declared in another file (that can be accessed) in the program.
They are in different scope.
2023-06-06 05:19 AM
Ok, i have found !
So in your main
extern UART_HandleTypeDef huart1;
instead of "UART_HandleTypeDef huart1; "
AND in your other file, add
UART_HandleTypeDef huart1;