HAL UART Library problem

General discussion on IDE.
Post Reply
Author
Message
sam.123.address@gmail.com
Posts: 11
Joined: 01 Aug 2023 15:25

HAL UART Library problem

#1 Post by sam.123.address@gmail.com » 26 Apr 2024 19:44

Hello i have looked at this example from Mikrosdk help examples it uses uart interrupts:

Code: Select all


/**
 * Any initialization code needed for MCU to function properly.
 * Do not remove this line or clock might not be set correctly.
 */
#ifdef PREINIT_SUPPORTED
#include "preinit.h"
#endif


//include files and opjects for UART
#include "MikroSDK.Hal.UART"
  
static hal_uart_t hal_uart;
 
// UART HAL config structure
static hal_uart_config_t hal_uart_cfg;
 
// Be careful to have large enough buffers
static uint8_t uart_rx_buffer[128];
 
// Be careful to have large enough buffers
static uint8_t uart_tx_buffer[128];

static size_t size;


//initialization function of UART
void application_init_uart ( void )
{
  
    // Fill structure with default values
    hal_uart_configure_default( &hal_uart_cfg );//uart_configure_default( &uart_cfg );

    // Specify desired UART RX pin
    hal_uart_cfg.rx_pin = PA10;
    
    // Specify desired UART TX pin
    hal_uart_cfg.tx_pin = PA9;
    
    // Declare buffer size
    hal_uart_cfg.tx_ring_size = sizeof(uart_tx_buffer);
    
    // Declare buffer size
    hal_uart_cfg.rx_ring_size = sizeof(uart_rx_buffer);
    
    if ( hal_uart_open( &hal_uart.handle, true ) == HAL_UART_ERROR )
    {
            // Error handling strategy
    }

}

int main(void)
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif

    application_init_uart ();

    while (1)
    {
       size = hal_uart_println( &hal_uart.handle, "Hello!" ); // Print out "Hello!" with new line every second.
       Delay_ms(1000);
    }

    return 0;
}

-The program compiles with no errors but in the UART terminal it doesn't display any message ! even though i tried check all the wiring and connections with the pc and mcu but with no success!.

-Second how can i use interrupt receive on rx pin ?

please MikroE team i have been trying for almost three days with no success please any help i have searched also Mikrosdk help but it doesn't contain any working example. I have also attached the project folder.

kind regards,
Sam
Attachments
UART_INTERRUPT.rar
(2.54 MiB) Downloaded 7 times

Post Reply

Return to “IDE General”