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); }
|