Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Hwi Interrupt on Sitara AM3359 (TMDXICE3359)

$
0
0

Hi!

I am trying to use the interrupt on a Sitara AM3359 chip. To do so, I am configuring my interrupt options coming from a timer. Since I cannot use the interrupt functions of Starterware, I am using the Hwi functions. Here is the code (in red is what is related to interrupt stuff):

Void taskFxn(UArg a0, UArg a1)
{
    char t_str[32];
    // Enable DMTimer3
                /* This function will enable clocks for the DMTimer3 instance */
                DMTimer3ModuleClkConfig();
                /* Load the counter with the initial count value */
                DMTimerCounterSet(SOC_DMTIMER_3_REGS, TIMER_INITIAL_COUNT);
                /* Load the load register with the reload count value */
                DMTimerReloadSet(SOC_DMTIMER_3_REGS, TIMER_RLD_COUNT);
                /* Configure the DMTimer for Auto-reload and compare mode */
                DMTimerModeConfigure(SOC_DMTIMER_3_REGS, DMTIMER_AUTORLD_NOCMP_ENABLE);
                DMTimerIntEnable(SOC_DMTIMER_3_REGS, DMTIMER_INT_OVF_EN_FLAG);
                DMTimerEnable(SOC_DMTIMER_3_REGS);

    while(1)
    {
        Task_sleep(250);
        UARTPutString(uartInstance,t_str);
    }

}
Void main()

{
    Hwi_Params hwiParams;

    Task_Handle task;
    Error_Block eb;

    System_printf("enter main() \n");

    // Initialize memory
    mmuInit(applMmuEntries);

    // Pin muxing
    AM335X_INDCOMM_MUX iceMux[] = {
        // SPI1 pinmux
        { 0x0994 , 3 , AM335X_PIN_OUTPUT },    //    spi1_d0_mux2/SIMO    mcasp0_fsx
        { 0x0998 , 3 , AM335X_PIN_INPUT_PULLUP },    //    spi1_d1_mux2/SOMI    mcasp0_axr0
        { 0x0990 , 3 , AM335X_PIN_OUTPUT | AM335X_PIN_INPUT_PULLDOWN },    //    spi1_sclk_mux2/CLK    mcasp0_aclkx . IMPORTATN: You need to enable both, input and output. Input clock is feed back into the RX logic of SPI.
        { 0x099c , 7 , AM335X_PIN_OUTPUT },    //    spi1_cs0_mux4: HVS SPI1 CS in GPIO mode
        { 0x09A0 , 7 , AM335X_PIN_OUTPUT },    //    gpio3[18]    mcasp0_aclkr -> INDUS_LDn
        {0xFFFFFFFF,0,0}
    };
    PINMUX_Config(iceMux);

    // Enable Outputs Leds
    led_init();
    // Enable Industrial Inputs
    spiInit();


    Error_init(&eb);
    task = Task_create(taskFxn, NULL, &eb);
    if (task == NULL) {
        System_printf("Task_create() failed!\n");
        BIOS_exit(0);
    }

    Hwi_Params_init(&hwiParams);
    hwiParams.arg = SYS_INT_TINT3;
    hwiParams.priority = 0;
    hwiParams.enableInt = FALSE;
    Hwi_create(SYS_INT_TINT3, DMTimerIsr, &hwiParams, NULL);
    Hwi_enableInterrupt(SYS_INT_TINT3);

    UartOpen(uartInstance, NULL);

    BIOS_start();     /* enable interrupts and start SYS/BIOS */
}
Void DMTimerIsr(UArg arg)
{
    /* Disable the DMTimer interrupts */
    DMTimerIntDisable(SOC_DMTIMER_3_REGS, DMTIMER_INT_OVF_EN_FLAG);

    /* Clear the status of the interrupt flags */
    DMTimerIntStatusClear(SOC_DMTIMER_3_REGS, DMTIMER_INT_OVF_IT_FLAG);

    UARTPutString(uartInstance,"We are in DMTimerIsr!\n");

    /* Enable the DMTimer interrupts */
    DMTimerIntEnable(SOC_DMTIMER_3_REGS, DMTIMER_INT_OVF_EN_FLAG);
}

The timer is working great. I can see it incrementing. And when the timer overflows, the program is stuck somewhere wrong, it is not is the main() neither in the DMTimerIsr().

Would you guys have an idea of what's wrong with my code ?

Thanks,
Have a nice week-end,
Paul

PS:
am335x_sysbios_ind_sdk_1.0.0.8
bios_6_35_00_20
xdctools_3_24_06_63


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>