Other Parts Discussed in Thread: BEAGLEBOARD-X15, , SYSBIOS
Tool/software: TI-RTOS
Hi,
I'm using Beagleboard-X15 (AM5728). I'm trying to send dummy values on default UART (UART3) to bluetooth module. I've created a task which I want to repeat every 250 ms. The attached code just send the information on UART just once and doesn't send it again.
Please help.
Thanks.
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Diags.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/Assert.h>
#include <xdc/runtime/Registry.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/MultiProc.h>
/*In case I need to print something and miscellaneous files*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* CSL Header files */
#ifdef _TMS320C6X
#include <ti/csl/csl_chip.h>
#endif
/* TI-RTOS Header files */
#include <ti/drv/gpio/GPIO.h>
#include <ti/drv/gpio/soc/GPIO_soc.h>
#include <ti/drv/gpio/test/led_blink/src/GPIO_log.h>
#include <ti/drv/gpio/test/led_blink/src/GPIO_board.h>
#include <ti/board/board.h>
/* UART Header files */
#include <ti/drv/uart/UART.h>
#include <ti/drv/uart/src/UART_osal.h>
#include <ti/csl/hw_types.h>
#include <ti/csl/soc.h>
#include <ti/drv/uart/UART_stdio.h>
#include <ti/drv/uart/test/src/UART_board.h>
/*Following has function calls used to communicate with ARM processor*/
#include "Server.h"
/**********************************************************************
************************** Internal functions ************************
**********************************************************************/
/* uart clock callback function */
void clock_fxn_uart(UArg arg);
/* Create a uart task*/
void uart_task_creation();
void UART_CrossbarConfigure(void);
void Board_initUART(void);
Void uart_test(UArg arg0, UArg arg1);
/**********************************************************************
************************** Global Variables **************************
**********************************************************************/
Clock_Handle hClockUart = NULL; // used for system clock for Uart
/*Function definitions*/
void Board_initUART(void)
{
Board_initCfg boardCfg;
boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK |
BOARD_INIT_UART_STDIO;
Board_init(boardCfg);
}
Void uart_test(UArg arg0, UArg arg1)
{
Board_initUART(); //Configure GPIO pins and UART
UART_CrossbarConfigure();
static int i=0;
char input = '\n';
char *buffPointer;
buffPointer = (char*)malloc(INPUT_LENGTH);
memset(buffPointer,0,INPUT_LENGTH);
//UART_puts("\nuart driver and utils example test cases :\nEnter 16 characters or press Esc \n",sizeof("uart driver and utils example test cases : please enter 16 characters or press Esc or carriage return\n"));
int w, y;
UART_puts("Value to TC1:",sizeof("Value to TC1:"));
UART_putc(i);
for (w=0; w<10000000; w++ )
{
for (y=0; y<10; y++ )
{
}
}
i++;
} /* uart_test */
/*
* Uart task created to output data to bluetooth
*/
void uart_task_creation()
{
/* Call board init functions */
Task_Handle taskUart;
Clock_Params clockParamsUart; // clock parameters created
Error_Block ebUart;
Board_initUART(); //Configure GPIO pins and UART
UART_CrossbarConfigure();
Error_init(&ebUart);
taskUart = Task_create(uart_test, NULL, &ebUart);
if (taskUart == NULL) {
System_printf("Task_create() failed!\n");
BIOS_exit(0);
}
/* setting up clock */
Clock_Params_init(&clockParamsUart);
clockParamsUart.period = 250; // set period
clockParamsUart.startFlag = FALSE; // don't know why it's false
hClockUart = Clock_create(clock_fxn_uart, TIMER_DELAY_UART, &clockParamsUart, &ebUart); // After every 5 ms call the function clockFxn
if (hClockUart == NULL) { // If clock creation is failed, throw an error and
System_printf("Clock_create() failed!\n"); // shutdown the processor
BIOS_exit(0);
}
}
/*
* clock_fxn_uart function: This is time triggered function. This is called every TIMER_DELAY_UART ms.
*/
void clock_fxn_uart(UArg arg) {
uart_test(NULL, NULL); // Start UART communication with bluetooth
}
/*
* ======== main ========
*/
int main(void)
{
uart_task_creation();
/* Start BIOS */
BIOS_start();
return (0);
}
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Diags.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/Assert.h>
#include <xdc/runtime/Registry.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/MultiProc.h>
/*In case I need to print something and miscellaneous files*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* CSL Header files */
#ifdef _TMS320C6X
#include <ti/csl/csl_chip.h>
#endif
/* TI-RTOS Header files */
#include <ti/drv/gpio/GPIO.h>
#include <ti/drv/gpio/soc/GPIO_soc.h>
#include <ti/drv/gpio/test/led_blink/src/GPIO_log.h>
#include <ti/drv/gpio/test/led_blink/src/GPIO_board.h>
#include <ti/board/board.h>
/* UART Header files */
#include <ti/drv/uart/UART.h>
#include <ti/drv/uart/src/UART_osal.h>
#include <ti/csl/hw_types.h>
#include <ti/csl/soc.h>
#include <ti/drv/uart/UART_stdio.h>
#include <ti/drv/uart/test/src/UART_board.h>
/*Following has function calls used to communicate with ARM processor*/
#include "Server.h"
/**********************************************************************
************************** Internal functions ************************
**********************************************************************/
/* uart clock callback function */
void clock_fxn_uart(UArg arg);
/* Create a uart task*/
void uart_task_creation();
void UART_CrossbarConfigure(void);
void Board_initUART(void);
Void uart_test(UArg arg0, UArg arg1);
/**********************************************************************
************************** Global Variables **************************
**********************************************************************/
Clock_Handle hClockUart = NULL; // used for system clock for Uart
/*Function definitions*/
void Board_initUART(void)
{
Board_initCfg boardCfg;
boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK |
BOARD_INIT_UART_STDIO;
Board_init(boardCfg);
}
Void uart_test(UArg arg0, UArg arg1)
{
Board_initUART(); //Configure GPIO pins and UART
UART_CrossbarConfigure();
static int i=0;
char input = '\n';
char *buffPointer;
buffPointer = (char*)malloc(INPUT_LENGTH);
memset(buffPointer,0,INPUT_LENGTH);
//UART_puts("\nuart driver and utils example test cases :\nEnter 16 characters or press Esc \n",sizeof("uart driver and utils example test cases : please enter 16 characters or press Esc or carriage return\n"));
int w, y;
UART_puts("Value to TC1:",sizeof("Value to TC1:"));
UART_putc(i);
for (w=0; w<10000000; w++ )
{
for (y=0; y<10; y++ )
{
}
}
i++;
} /* uart_test */
/*
* Uart task created to output data to bluetooth
*/
void uart_task_creation()
{
/* Call board init functions */
Task_Handle taskUart;
Clock_Params clockParamsUart; // clock parameters created
Error_Block ebUart;
Board_initUART(); //Configure GPIO pins and UART
UART_CrossbarConfigure();
Error_init(&ebUart);
taskUart = Task_create(uart_test, NULL, &ebUart);
if (taskUart == NULL) {
System_printf("Task_create() failed!\n");
BIOS_exit(0);
}
/* setting up clock */
Clock_Params_init(&clockParamsUart);
clockParamsUart.period = 250; // set period
clockParamsUart.startFlag = FALSE; // don't know why it's false
hClockUart = Clock_create(clock_fxn_uart, TIMER_DELAY_UART, &clockParamsUart, &ebUart); // After every 5 ms call the function clockFxn
if (hClockUart == NULL) { // If clock creation is failed, throw an error and
System_printf("Clock_create() failed!\n"); // shutdown the processor
BIOS_exit(0);
}
}
/*
* clock_fxn_uart function: This is time triggered function. This is called every TIMER_DELAY_UART ms.
*/
void clock_fxn_uart(UArg arg) {
uart_test(NULL, NULL); // Start UART communication with bluetooth
}
/*
* ======== main ========
*/
int main(void)
{
uart_task_creation();
/* Start BIOS */
BIOS_start();
return (0);
}