Skip to content

without this the ping test fails oO#11

Closed
yogo1212 wants to merge 1 commit intocc26x0_rfcfrom
possible_race
Closed

without this the ping test fails oO#11
yogo1212 wants to merge 1 commit intocc26x0_rfcfrom
possible_race

Conversation

@yogo1212
Copy link
Copy Markdown
Owner

No description provided.

@yogo1212
Copy link
Copy Markdown
Owner Author

without printf:

2016-05-26 18:16:41,435 - INFO # main(): This is RIOT! (Version: 2016.03-devel-1809-g273f2f-brot-cc26x0_rfc)
2016-05-26 18:16:41,437 - INFO # Hello World!
2016-05-26 18:16:41,438 - INFO # RFC_PWR->PWMCLKEN 7ff
2016-05-26 18:16:41,440 - INFO # cpe1 0x60000000
2016-05-26 18:16:41,443 - INFO # Command acknowledged. CMDSTA: 0x130 
2016-05-26 18:16:41,445 - INFO # rfc_ping_test failed

@yogo1212
Copy link
Copy Markdown
Owner Author

yogo1212 commented May 26, 2016

with:

2016-05-26 18:17:44,697 - INFO # main(): This is RIOT! (Version: 2016.03-devel-1809-g273f2f-brot-cc26x0_rfc)
2016-05-26 18:17:44,698 - INFO # Hello World!
2016-05-26 18:17:44,699 - INFO # RFC_PWR->PWMCLKEN 7ff
2016-05-26 18:17:44,701 - INFO # cpe1 0x60000000
2016-05-26 18:17:44,704 - INFO # Command acknowledged. CMDSTA: 0x1 //ping
2016-05-26 18:17:44,705 - INFO # cmdsta: 1
2016-05-26 18:17:44,708 - INFO # Command acknowledged. CMDSTA: 0x1 //nop
2016-05-26 18:17:44,709 - INFO # cpe0 0x3
2016-05-26 18:17:44,712 - INFO # Command acknowledged. CMDSTA: 0x1 //setup_ble
2016-05-26 18:17:44,713 - INFO # cpe0 0x3
2016-05-26 18:17:44,732 - INFO # Command acknowledged. CMDSTA: 0x1 //pings in rfc_ble_beacon
2016-05-26 18:17:44,752 - INFO # Command acknowledged. CMDSTA: 0x1

@yogo1212
Copy link
Copy Markdown
Owner Author

yogo1212 commented May 26, 2016

i'm hungry..
the printf is being run after the interrupt. how can the printf by its mere presence - without being run - change the return value of the rfcore?!

@fvcoen
Copy link
Copy Markdown
Collaborator

fvcoen commented May 27, 2016

I've encountered this problem before: I honestly don't know what causes it. At the time, I kept rearranging my code (as in physically changing the order of the lines) and at some point the command stopped failing...
In my testing, I've tried to repeat the exact same code multiple times and the command only fails when the rfc_ping_test function is called.

void rfc_ping_test2(void) {
  direct_command_t pingCommand;
  pingCommand.commandID = CMDR_CMDID_PING;
  RFC_DBELL->CMDR |= (uint32_t) (&pingCommand);
  while(!RFC_DBELL->CMDSTA);
}

void rfc_test_cmd(void)
{
    printf("\n===> %s <===\n",__FUNCTION__);

    printf("\nDirect command...\n");
    direct_command_t pingCommand; //first command
    pingCommand.commandID = CMDR_CMDID_PING;
    RFC_DBELL->CMDR |= (uint32_t) (&pingCommand);
    while (!RFC_DBELL->CMDSTA); /* wait for cmd execution */
    direct_command_t pingCommand2; //second command
    pingCommand2.commandID = CMDR_CMDID_PING;
    RFC_DBELL->CMDR |= (uint32_t) (&pingCommand2);
    while(!RFC_DBELL->CMDSTA);
    rfc_ping_test2(); //third command 
    direct_command_t pingCommand3; //forth command
    pingCommand3.commandID = CMDR_CMDID_PING;
    RFC_DBELL->CMDR = (uint32_t) (&pingCommand3);
    while (!RFC_DBELL->CMDSTA); /* wait for cmd execution */
    printf("cmdsta: %lu\n", RFC_DBELL->CMDSTA);

Result:

 Command acknowledged. CMDSTA: 0x1 
 Command acknowledged. CMDSTA: 0x1 
 Command acknowledged. CMDSTA: 0x130 
 Command acknowledged. CMDSTA: 0x1 
 cmdsta: 1

This only seems to happen with direct command. Moreover the CMDSTA code changes, sometimes 0x130 other time 0x135, neither of which are documented.

My guess: there is a low-leve bug and the status code returned in the interrupt is in fact a temporary state of the CMDSTA register.

@yogo1212
Copy link
Copy Markdown
Owner Author

@fvcoen thank you very much for your insight 👍
very weird

@yogo1212 yogo1212 closed this Jun 2, 2016
@fvcoen
Copy link
Copy Markdown
Collaborator

fvcoen commented Jun 24, 2016

@yogo1212
UPDATE: so it turns out i'm an idiot :) the problem is in the format used in printf(): 0x%" PRIu32 "doesn't display the register state correctly. If you use 0x%08lx or 0x%" PRIx32 " 0x130 becomes 0x00000082, an error code meaning that The command ID number in the command structure is unknown...

Now it doesn't make much sense that the position of a printf would change the parsing of the command but you know... it makes a little more sense (i think?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants