Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

send hex data by uart

Posted by mcgilbarron on March 18, 2014

I am using the lpcxxpresso 1769, I need to create a task that runs every 10 seconds automatically and to transmit a series of numbers in hexadecimal format: unsigned portCHAR pcCall[ 36 ]={0xbf, 0xff, 0x00, 0x1F, 0x43, 0x41, 0x4C, 0x4C, 0x20, 0x30, 0x30, 0x3A, 0x30, 0x37, 0x3A, 0x38, 0x30, 0x3A, 0x39, 0x62, 0x3A, 0x30, 0x38, 0x3A, 0x31, 0x62, 0x20, 0x31, 0x30, 0x30, 0x31, 0x20, 0x48, 0x44, 0x50, 0x0A}; I try to modify the task vUARTCommandConsoleStart() on the sample FreeRTOS+IO; but only the first two bytes transmitted and aborts program execution, could someone tell me how I can create a task that runs independently and forward numbers in hexadecimal format?


send hex data by uart

Posted by davedoors on March 18, 2014

How do you want the numbers to appear? As ascii or binary?

If binary then you should be able to just send the start and length of pcCall to any suitable UART send function.

If as ascii then with the 0x in front of each number of witout and with a comma between each number of without? In all cases you should be able to use sprintf() to format the string in a temporary buffer then send the start and length of the temporary buffer to any suitable UART send function.


send hex data by uart

Posted by mcgilbarron on March 19, 2014

could you five commercial suport? I need help for create a task for send hexadecimal characters, i tried but freertos not allow me to add a task,and tried to do it in different ways but only sends data in response to a command registered by FreeRTOS_CLIRegisterCommand.


send hex data by uart

Posted by rtel on March 19, 2014

Commercial support should not be necessary - all that is necessary is to understand what it is you are trying to do. If you went the commercial route they would just ask the same questions because they to would need to understand what you are trying to do.

Is creating the task the problem? Or sending to the UART? Or the format of what you are trying to send to the UART?

Regards.


send hex data by uart

Posted by mcgilbarron on March 19, 2014

Ok, I need to create using the next function, the next funcion usually works using a FreeRTOSCLIRegisterCommand(&xSampleAdc) action, but now I need to this begin from any task without using a command reception to start. is it possible?

static portBASETYPE prvSampleAdcCommand( int8t *pcWriteBuffer, sizet xWriteBufferLen, const int8t *pcCommandString ) { PRIVILEGEDDATA static char pcString2[ 50 ] ;

char cont=0;
Resultado=0;
Resultado=RTC_GetTime(LPC_RTC,RTC_TIMETYPE_SECOND);
*pcWriteBuffer = ( signed char ) 0x00;

char *ptr = "inicio muestra\n";//agregado
strcat( ( char* ) pcWriteBuffer, ( char* ) ptr );//agregado

strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );
sprintf(pcString2,"%d\n", Resultado);
strcat( ( char * ) pcWriteBuffer, ( char * ) pcString2 );

getADCsample ( );

 for (cont=0;cont<200;cont++)
  {
    sprintf(pcString2,"%02x\n",val[cont] );
    strcat( ( char * ) pcWriteBuffer, ( char * ) pcString2 );
  }
    strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );
    char *ptr2 = "fin muestra\n";//agregado
 	strcat( ( char* ) pcWriteBuffer, ( char* ) ptr2 );//agregado

pdFALSE. */ return pdFALSE; }


send hex data by uart

Posted by rtel on March 19, 2014

So the function you have posted (prvSampleAdcCommand()) generates a string that contains some data. You say in your post that generating the string works ok when prvSampleAdcCommnad() is called in response to somebody typing a command into the CLI. Now you want to call the same function from C code, rather than from the CLI?

If so, then you can just make the function non-static and call it directly.

Alternatively paste the same code into a new function and call that.

In the function you posted I don't see the string being sent to a UART. Do you have a UART send function you can use? If not you can get a suitable function from the LPCWare.com website as NXP provide drivers for this chip.

Regards.


send hex data by uart

Posted by mcgilbarron on March 20, 2014

Thanks for your help. Now I am having problems when using strcat, the program aborts execution when i use it, and I dont now why?

void vSendStringSerial ( void *pvParameters) { int8t cRxedChar, cInputIndex = 0, *pcOutputString; static int8t cInputString[ cmdMAXINPUTSIZE ]; portBASETYPE xReturned; int8t *pcWriteBuffer=( signed char ) 0x00; char *pcString[ 50 ]; unsigned portSHORT val=100;

( void ) pvParameters;
pcOutputString = FreeRTOS_CLIGetOutputBuffer();
xConsoleUART = FreeRTOS_open( boardCOMMAND_CONSOLE_UART, ( uint32_t ) cmdPARAMTER_NOT_USED );
configASSERT( xConsoleUART );
xReturned = FreeRTOS_ioctl( xConsoleUART, ioctlUSE_ZERO_COPY_TX, cmdPARAMTER_NOT_USED );
configASSERT( xReturned );
xReturned = FreeRTOS_ioctl( xConsoleUART, ioctlUSE_CHARACTER_QUEUE_RX, ( void * ) cmdMAX_INPUT_SIZE );
configASSERT( xReturned );
xReturned = FreeRTOS_ioctl( xConsoleUART, ioctlSET_INTERRUPT_PRIORITY, ( void * ) ( configMIN_LIBRARY_INTERRUPT_PRIORITY - 1 ) );
configASSERT( xReturned );

sprintf( ( char * )pcString,"%x\n", 0x64);
strcat( ( char * ) pcWriteBuffer, ( char * ) pcString );



if( FreeRTOS_ioctl( xConsoleUART, ioctlOBTAIN_WRITE_MUTEX, cmd50ms ) == pdPASS )
	{
		FreeRTOS_write( xConsoleUART, pcWriteBuffer, strlen( ( char * ) pcWriteBuffer ) );
	}

}

attribute ((section(".aftervectors"))) void HardFaultHandler(void) { _asm volatile ( " tst lr, #4 n" " ite eq n" " mrseq r0, msp n" " mrsne r0, psp n" " ldr r1, [r0, #24] n" " ldr r2, handleraddressconst n" " bx r2 n" " handleraddressconst: .word popregistersfromfault_stack n" ); }

Attachments

BlueAgent.zip (7997747 bytes)

send hex data by uart

Posted by rtel on March 20, 2014

Do you have stack overflow protection turned on? http://www.freertos.org/Stacks-and-stack-overflow-checking.html

Are you running a recent version (7.6.0 or higher) with configASSERT() defined to give you the extra error checking included in those versions? http://www.freertos.org/a00110.html#configASSERT

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS