General Exceoption

Fully featured ARM compilers available on Windows, Linux, and macOS.
Post Reply
Author
Message
kamputty
Posts: 31
Joined: 22 Aug 2012 21:34

General Exceoption

#1 Post by kamputty » 04 Feb 2023 18:03

Hi all,

just getting familiar with the new [to me] Necto C AI [for pic32] ecosystem...I'm doing a simple UART read/echo (from examples) and I seem to be getting a General Exception issue (drops into the __GenExcept() handler)...

Here is my simple code. It dies in the uart_open call...All vanilla setup on Fision Pic32 v8 board.

Thoughts?

~Kam

Code: Select all

#include "MikroSDK.Board"
#include "MikroSDK.MikroBus"
#include "MikroSDK.Driver.UART"
#include "MikroSDK.Hal.GPIO"

uart_t        uart;
uart_config_t uart_cfg;

static uint8_t buffer[16];
static uint8_t size;

static uint8_t uart_rx_buffer[256];
static uint8_t uart_tx_buffer[256];

void application_init(void)
{
    // take default conf
    uart_configure_default(&uart_cfg);

    uart_cfg.rx_pin = USB_UART_RX;
    uart_cfg.tx_pin = USB_UART_TX;

    uart_cfg.tx_ring_size = sizeof(uart_tx_buffer);
    uart_cfg.rx_ring_size = sizeof(uart_rx_buffer);

    // lets open and catch any errors...
    if(uart_open(&uart, &uart_cfg) == UART_ERROR)
    {
        while (1)
        {
            asm nop;
        }
    }

    uart_set_baud(&uart, 115200);

    uart_println(&uart, "Starting echo:");
}

void application_task(void)
{
    size = uart_read(&uart, buffer, sizeof(buffer));

    if(size)
    {
        uart_write(&uart, buffer, size);
    }
}

void main(void)
{
    application_init();

    while (1)
    {
        application_task();
    }
}

kamputty
Posts: 31
Joined: 22 Aug 2012 21:34

Re: General Exceoption

#2 Post by kamputty » 07 Feb 2023 16:48

Hi all,

Okay, here is a complete program....I still get the general exception!
Can others run it and see if you get it too please? It dies at the uart_open call...Fusion for PIC32 v8, NECTO 2.5.0
I know it works as I can use the same hardware on MPLABX just fine...

~Kam

Code: Select all

#include "MikroSDK.Board"
#include "MikroSDK.Driver.UART"

static uart_t uart;
static uart_config_t uart_cfg;
static uint8_t uart_rx_buffer[128];
static uint8_t uart_tx_buffer[128];

void main(void)
{
    uart_configure_default(&uart_cfg);
    uart_cfg.rx_pin = USB_UART_RX;
    uart_cfg.tx_pin = USB_UART_TX;
    uart_cfg.tx_ring_size = sizeof(uart_tx_buffer);
    uart_cfg.rx_ring_size = sizeof(uart_rx_buffer);
    uart_set_baud(&uart, 38400); 

    // lets open and catch any errors...
    if(uart_open(&uart, &uart_cfg) == UART_ERROR)
    {
        while (1)
        {
            asm nop;
        }
    }

    uart_println(&uart, "Hello World!");
}

kamputty
Posts: 31
Joined: 22 Aug 2012 21:34

Re: General Exceoption

#3 Post by kamputty » 07 Feb 2023 17:03

okay, making headway...

I traced the crash, and it happens in file hal_uart.c, in function ring_buf8_init.

And when I trace into that function, I see that the pointer to the ring buffer is NULL.

I don't see where I assign/point to my ring buffers in the code. I didn't see any API's for that...

So how do I assign my buffers to the uart subsystem? Thats causing my fault...memset to a null...☹

~Kam

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: General Exceoption

#4 Post by IvanJeremic » 08 Feb 2023 15:47

Hi,

Can you tell me what MCU you are using so i can try to replicate the issue?

Regards,

Ivan.

kamputty
Posts: 31
Joined: 22 Aug 2012 21:34

Re: General Exceoption

#5 Post by kamputty » 08 Feb 2023 16:04

PIC32MX795F512L, fusion v8, latest necto

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: General Exceoption

#6 Post by IvanJeremic » 09 Feb 2023 09:59

Hi,

Try it out with the code below:

Code: Select all

#include "MikroSDK.Board"
#include "MikroSDK.Driver.UART"

static uart_t uart;
static uart_config_t uart_cfg;
static uint8_t uart_rx_buffer[128];
static uint8_t uart_tx_buffer[128];

void main(void)
{
    uart_configure_default(&uart_cfg);
    uart_cfg.rx_pin = USB_UART_RX;
    uart_cfg.tx_pin = USB_UART_TX;
    uart_cfg.tx_ring_size = sizeof(uart_tx_buffer);
    uart_cfg.rx_ring_size = sizeof(uart_rx_buffer);
    uart.tx_ring_buffer = uart_tx_buffer;
    uart.rx_ring_buffer = uart_rx_buffer;

    // lets open and catch any errors...
    if(uart_open(&uart, &uart_cfg) == UART_ERROR)
    {
        while (1)
        {
            asm nop;
        }
    }
    
    uart_set_baud(&uart, 38400);

    uart_println(&uart, "Hello World!");
}
There are small differences, the example that we have in the drv_uart.h header is not complete so that is a mistake on our part.
drv_uart.zip
(4.05 KiB) Downloaded 34 times
Also note that you need to open the Uart before setting the baudrate.

Regards,

Ivan.

kamputty
Posts: 31
Joined: 22 Aug 2012 21:34

Re: General Exceoption

#7 Post by kamputty » 09 Feb 2023 10:10

thanks Ivan!

It works great!

~Kam

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: General Exceoption

#8 Post by IvanJeremic » 10 Feb 2023 15:21

Hi,

Glad i could help!

Regards,

Ivan.

Post Reply

Return to “PIC32 AI Compilers”