Hi guys I am a new learner in this field; I am working on STR912x;
I am using the following code for sending a string which have saved in memory
memset(sign_packet_data, 0, 0xFF); sign_packet_data = &sign_UART_txBuff[0];//char *sign_packet_data =0; strncpy(sign_packet_data, cmd,16);//cmd stores the string if(sign_packet_data != 0) { NbrOfDataToTransfer = strlen(sign_UART_txBuff); while(NbrOfDataToTransfer--) { UART_SendData(UART0, sign_UART_txBuff[TxCounter++]); while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET); } }
may i have a better way to do the same.
In what field, exactly?
- in any form of programming?
- in 'C' programming specifically?
- with microcontrollers generally?
- with the STR912x specifically?
For some basic tips on learning 'C', see: blog.antronics.co.uk/.../
with the STR912x specifically:
I wish to know if I can use some function other than copying the data in the txbuffer everytime i.e. strcpy
But there is nothing in the code you posted that relates specifically to the STR912x - it is all entirely generic 'C' code!!
"I wish to know if I can use some function other than copying the data in the txbuffer everytime e.g. strcpy"
Of course you can - why ever not?!
OK, so this is rather specifc:
while( UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET );
But it could easily (and should?) be generalised to:
while( UART_IsBusy(UART0) );
or similar - thus keeping all the target-specific detail separate from the generic string handling.