⚠️
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.
13 posts / 0 new
Last post
YehudaNovodes
Offline
Last seen:2 years 3 months ago
加入:2018-11-11 12:38
Sending 0 via UART

Hi all,

I'm working now on the DA14580 BLE module with SDK 5.0.4 and I can't send 0 via arch_printf command.
When sending 0, the FW jumps to hardfault_handler.c file to line 141 and stay there.
if ((GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP)
__asm("BKPT #0\n");

any help will be great.

Keywords:
Device:
PM_Dialog
Offline
Last seen:1 day 22 hours ago
Staff
加入:2018-02-08 11:03
Hi YehudaNovodes,

Hi YehudaNovodes,

I tried to replicate the issue that you have mentioned but I am able to send “0” via arch_printf(). 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("0"); into adv_data_update_timer_cb() function. So, I am sending “0” every 10 seconds.
  3. Change the baud rate of the terminal into 115200.

If I understood anything wrong, please let me know what you are trying to accomplish or provide me hot to call the arch_printf() into your code.

Thanks, PM_Dialog

YehudaNovodes
Offline
Last seen:2 years 3 months ago
加入:2018-11-11 12:38
Sorry for not being clear

Sorry for not being clear enough.

Yes, I can send 0 via arch_printf.
The problem is when I'm trying to echo the input over UART. If one of the bytes inserted was 0x00, then when I'm trying to print the elements of an array that holds this byte, I get this error. I believe the reason is that 0 does not consider as a "value", so when I'm trying to print it, it can't find something to print and hence the error.

YehudaNovodes
Offline
Last seen:2 years 3 months ago
加入:2018-11-11 12:38
I checked the issue a bit

I checked the issue a bit more and I think I'm sure what is the problem now.

I use the arch_printf function to print an array. So if, for example, the content of the array is:

ExampleArr[2] = {0x01, 0x02};

and I'm trying to run:

arch_printf (ExampleArr);

the print out is 01, 02 which is exactly what I want. The problem starts when the first element of ExampleArr is 0x00, then the SW runs into

if ((GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP)
__asm("BKPT #0\n");

error.
If the second element is 0x00 there's no problem.
When I'm trying to use arch_printf to print 0 like this:

ExampleVar = 0;
arch_printf("%x", ExampleVar);

there's no error but what's actually printed is the ASCII value of 0, which is 30. I need the 0 value to be printed, not the symbol...

PM_Dialog
Offline
Last seen:1 day 22 hours ago
Staff
加入:2018-02-08 11:03
Hi YehudaNovodes,

Hi YehudaNovodes,

Could you please try this code snippet?

uint8_t ExampleArr[3] = {0x00, 0x01 , 0x02};

for( uint8_t i = 0 ; i <3 ; i++)

{

arch_printf("%x",ExampleArr[i]);

}

arch_printf("\n\r");

Otherwise, please provide me your code snippet as you are using it into your firmware.

Thanks, PM_Dialog

YehudaNovodes
Offline
Last seen:2 years 3 months ago
加入:2018-11-11 12:38
Hi,

Hi,

As I mentioned, the arch_printf function gets the array to print by address arch_printf(ExampleArr) and not by value arch_printf(ExampleArr[i]). To be more clear, if I have a variable called ExampleVar = 0x01, then writing arch_printf (&ExampleVar) ends up with 1, printed on terminal but if ExampleVar = 0x00, the arch_printf(&ExampleVar) ends up with error!!

我没有使用你的方法的原因是价值e printed out is NOT the actual value but its ASCII compatible. So, if I'll return to my previous example, this is how it looks in both cases:
1)
ExampleVar = 0x01;
arch_printf(&ExampleVar);
Print out is: 1

ExampleVar = 0x00;
arch_printf(&ExampleVar);
Print out is: error

2)
ExampleVar = 0x01;
arch_printf ("%x", ExampleVar);
Print out is: 31

ExampleVar = 0x00;
arch_printf ("%x", ExampleVar);
Print out is: 30

I really hope the problem is clear now...

PM_Dialog
Offline
Last seen:1 day 22 hours ago
Staff
加入:2018-02-08 11:03
Hi YehudaNovodes,

Hi YehudaNovodes,

Apologies for the delay. I tried to test your code, this code snippet arch_printf(&ExampleVar) cannot be built by the Keil. This is a quite strange situation, because if I understood correctly this can be built from your side. Also, I have different results than yours. Please check the following:

ExampleVar = 0x01;

arch_printf ("%x", ExampleVar);

Print out is: 1 (and NOT 31 which is the ASCII character of 1)

ExampleVar = 0x00;

arch_printf ("%x", ExampleVar);

Print out is: 0 (and NOT 30 which is the ASCII character of 0)

Could you please let me know if you have modified the source code of the arch_printf() function? Could you please try to do the same in a new SDK path? Be aware that I am using the latest SDK of D14580 series (SDK5.0.4)

Thanks, PM_Dialog

YehudaNovodes
Offline
Last seen:2 years 3 months ago
加入:2018-11-11 12:38
Hi,

Hi,

No, I haven't modified your source code of arch_prinf at all.
But I have a better solution. For printing an array of any value at any location, I just used the uart2_write(*arr, Size, NULL) function, when *arr is the pointer to the printed array, Size is the size to be printed, in bytes, and NULL is the NULL pointer, as required in the description of the function.

PM_Dialog
Offline
Last seen:1 day 22 hours ago
Staff
加入:2018-02-08 11:03
Hi YehudaNovodes,

Hi YehudaNovodes,

Since that you didn’t modified the arch_prinf() function, it is a little bit strange because I get different results from yours. By the way, glad that you figured your issue out and that for your indication.

Thanks, PM_Dialog

Dionysus
Offline
Last seen:2 years 2 months ago
加入:2019-01-13 14:48
Dear forum experts,

Dear forum experts,
I'm working on DA14580 with the sdk5.0.4.

I want to know How does the host receive SMP requests from the slave.
I had run my code,attach below,sniff the slave but there's no CALLBACK in the user functions.
it seems it was invalid?

How does the host receive SMP requests from the slave?

Thanks in advcance,
Dionysus

Attachment:
PM_Dialog
Offline
Last seen:1 day 22 hours ago
Staff
加入:2018-02-08 11:03
Hi Dionysus,

Hi Dionysus,

Thanks for your question but it is not related with this forum thread. If I understood correctly the DA14580 is acting as a central. Since you are a central, you cannot request security from a peripheral. If you have any other follow-up questions, please create a new forum thread. If you don’t know hot to create a new forum thread, please let me know and I will provide you the appropriate steps.

Thanks, PM_Dialog

chenpenglai
Offline
Last seen:2 months 5 days ago
加入:2018-12-24 02:24
Hi YehudaNovodes,

Hi YehudaNovodes,

you might try my code which can send hex, as follows:

extern void uart_callback(uint8_t res);

uint8_t data=0x00;

uart2_write(&data, 1, uart_callback);

PM_Dialog
Offline
Last seen:1 day 22 hours ago
Staff
加入:2018-02-08 11:03
Hi chenpenglai,

Hi chenpenglai,

Thanks for your indication.

Regards, PM_DIalog