⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
Jasu
Offline
Last seen:1 year 10 months ago
加入:2019-01-23 10:26
decimal values in uart

i want to print decimal value of equalent binary vale. how can i print binary values in uart ?

printf_byte_dec function is not working!!!???

Keywords:
Device:
PM_Dialog
Offline
Last seen:41 min 21 sec ago
工作人员
加入:2018-02-08 11:03
Hi Jasu,

Hi Jasu,

The the printf_byte_dec() function that will print a byte value in decimal format. When using the BLE examples you can use the arch_printf() function for debugging where you can choose the format between decimal, hexadecimal, character or string. Could you please provide me a short code snippet? Which are your results?

Thanks, PM_Dialog

Jasu
Offline
Last seen:1 year 10 months ago
加入:2019-01-23 10:26
voltage=(adc_value*5)/1023;

voltage=(adc_value*5)/1023;
printf_byte_dec(voltage);
printf_string("\n\r\n\r");
resistance=( (5 * ( 100.0 / voltage ) ) - 100 );
Rln=log(resistance);
temperature = ( 1 / ( 0.001129148 + ( 0.000234125 *Rln) + ( 0.0000000876741 * Rln * Rln* Rln) ) );
printf_byte_dec(temperature);

but nothing is printed on uart?

if iam using printf_byte i will get hex values !!

how to fix this? is is it possible to print decimal values?

PM_Dialog
Offline
Last seen:41 min 21 sec ago
工作人员
加入:2018-02-08 11:03
Hi Jasu,

Hi Jasu,

In my previous post, I suggested you to use the arch_printf () API from arc_console.h library. I worked on the ble_app_barebone example of the SDK 5.0.4 and I used the Pro-DK. Let me describe what I did and make sure that you have done the same configurations.

  1. #define CFG_PRINTF in the da1458x_config_basic.h
  2. Change the uart ports of the fw and assign the UART_TX port/pin to P04 and UART_RX port/pin to P05 (make sure that the configuration that you have changed is under the HW_CONFIG_PRO_DK and that this the board declared in the HW_CONFIG definition).

#elif HW_CONFIG_PRO_DK

#define UART2_TX_GPIO_PORT GPIO_PORT_0

#define UART2_TX_GPIO_PIN GPIO_PIN_4

#define UART2_RX_GPIO_PORT GPIO_PORT_0

#define UART2_RX_GPIO_PIN GPIO_PIN_5

If you have one other of our DKs or if you are working on a custom board, please modify the definitions above with the appropriate GPIOs

  1. Include the arch_console.h file into user_barebone.c
  2. Invoke arch_printf()
  3. Change the baud rate of the terminal into 115200.

In order to print decimal values you should use the “%d” in the arch_printf(). Please check some example codes.

uint8_t my_data[3] = {10 , 11 , 12}; //decimal arch_printf("uint8_t my_data[3] = {10 , 11 , 12}; //decimal"); arch_printf("\r\n"); arch_printf("DEC: %d %d %d" ,my_data[0] ,my_data[1],my_data[2]); arch_printf("\r\n"); arch_printf("HEX: %x %x %x" ,my_data[0] ,my_data[1],my_data[2]); arch_printf("\r\n"); arch_printf("\r\n"); uint8_t my_data_hex[3] = {0x10 , 0x11 , 0x12}; //hex arch_printf("uint8_t my_data_hex[3] = {0x10 , 0x11 , 0x12}; //hex"); arch_printf("\r\n"); arch_printf("DEC: %d %d %d" ,my_data_hex[0] ,my_data_hex[1],my_data_hex[2]); arch_printf("\r\n"); arch_printf("HEXL %x %x %x" ,my_data_hex[0] ,my_data_hex[1],my_data_hex[2]);

If you would like to print floating point numbers. You should follow the procedure described in the below forum thread:

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-%E2%80%93-software/floating-point

Thanks, PM_Dialog