Hi JuroV,
Thankyou for your reply. This mail helped me a lot in learning UART code.. After going thorugh the files i wrote an UART0 code as below
extern void main_task(uint_32);
extern void uart0_task(uint_32);
#define UART0_TASK 11
TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
{ 10, main_task, 2000, 9, "Main",MQX_AUTO_START_TASK, 0, 0},
{ UART0_TASK, uart0_task, 2000, 8, "uart0",0, 0, 0},
{ 0, 0, 0, 0, 0, 0,0, 0}
};
void main_task
(
uint_32 initial_data
)
{
_task_id uart0_task_id;
uart0_task_id = _task_create(0, UART0_TASK, 0);
if(uart0_task_id == MQX_NULL_TASK_ID)
{
printf("\n could not create uart0 task \n");
_mqx_exit(0);
}
else
{
}
}
void uart0_task(uint_32 initial_data)
{
pointer uart0_ptr;
char Z, uart0[200];
uint_16 i = 0;
volatile boolean result=0xdeadbeef;
uart0_ptr = (pointer)fopen("ittya:",BSP_DEFAULT_IO_OPEN_MODE);
if(uart0_ptr == NULL)
{
printf("cannot open ittya device \n");
}
else
{
printf("device opened succesfully \n");
fflush(stdout);
}
while(1)
{
read(uart0_ptr,(pointer)&Z,1);
uart0[i] = Z;
//dont know why this checking is done ... please explain me this
if(result = fstatus(uart0_ptr))
{
}
else
{
if(uart0[i] == 0x31)
{
if(i ==45)
{
i =0;
}
else
{
i++;
}
write(uart0_ptr,(pointer)"\n",1);
write(uart0_ptr,(pointer)"Y",1);
}
else
{
}
}
}
}
After i flash and run the above code it should send "Y" to the comm port if i press 1 on the key board but it sends "1Y" as output instead . I dont know why is this happening ?
Looking forward for your suggestion in sorting out this :smileysad:
Thanks and Regards
Sai Bhargavi