Other Parts Discussed in Thread: SYSBIOS
Hi Experts,
Currently i am trying to write the interrupt count to UART and Print the data based on UART input so i take UART echo and GPIO interrupt example for this but i can't print the interrupt count i have tried lot of method for this but i can't achieve the output so kindly suggest the best way to achieve the output
i have shared my code for your reference
i want to print interrupt count when i press the button
*/ ======== uartecho.c ========
*/
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>
/* Example/Board Header files */
#include "Board.h"
#include "UARTUtils.h"
#include <stdint.h>
#define TASKSTACKSIZE 768
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
int count = 0;
void gpioButtonFxn0(unsigned int index)
{
/* Clear the GPIO interrupt and toggle an LED */
GPIO_toggle(Board_LED0);
if (count++ == 100) {
count = 0;
}
}
void gpioButtonFxn1(unsigned int index)
{
/* Clear the GPIO interrupt and toggle an LED */
GPIO_toggle(Board_LED1);
if (count++ == 100) {
count = 0;
}
}
Void echoFxn(UArg arg0, UArg arg1)
{
char input;
UART_Handle uart;
UART_Params uartParams;
const char echoPrompt[] = "\fEchoing characters:\r\n";
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 9600;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {
System_abort("Error opening the UART");
}
UART_write(uart, echoPrompt, sizeof(echoPrompt));
/* Loop forever echoing */
while (1) {
UART_read(uart, &input, 1);
UART_write(uart, &input, 1);
}
}
/*
* ======== main ========
*/
int main(void)
{
/* Call board init functions */
Board_initGeneral();
Board_initGPIO();
Board_initUART();
/* Construct BIOS objects */
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
taskParams.instance->name = "echo";
Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);
/* Turn on user LED */
GPIO_write(Board_LED0, Board_LED_ON);
// UARTUtils_systemInit(0);
/* This example has logging and many other debug capabilities enabled */
System_printf("This example does not attempt to minimize code or data "
"footprint\n");
System_flush();
System_printf("Starting the UART Echo example\nSystem provider is set to "
"SysMin. Halt the target to view any SysMin contents in "
"ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
/* install Button callback */
GPIO_setCallback(Board_BUTTON0, gpioButtonFxn0);
/* Enable interrupts */
GPIO_enableInt(Board_BUTTON0);
/*
* If more than one input pin is available for your device, interrupts
* will be enabled on Board_BUTTON1.
*/
if (Board_BUTTON0 != Board_BUTTON1) {
/* install Button callback */
GPIO_setCallback(Board_BUTTON1, gpioButtonFxn1);
GPIO_enableInt(Board_BUTTON1);
}
/* Start BIOS */
BIOS_start();
return (0);
}
regards
surya