This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

A function work difference in difference .c in BasicRF

Other Parts Discussed in Thread: CC2530

I am to do a UART cmd parse with light_switch example in BasicRF,but the parse function work error.

code:

the parse function:

void HalATPoll(void)
{
  if (g_at) {
    trace("at %d:", g_buflen);
    log_hex(g_rxbuf, g_buflen);
    trace("\r\n");
    g_buflen = 0;
    g_at = FALSE;
  }
}

when the function is put in light_switch.c, it works well.  when cc2530 recv uart cmd, the func printf the "at xx:xx xx" very well.

when the function is put in my app_at.c, it works error, it can't printf anything. And my app_at.c is just filled with the same function and declaration. 

  • Where is g_at initialized to true?
  • g_at is set in the uart cb.

    this is the cb func:

  • Hi , it seems to be work out, it's maybe about the clib and IAR setting, but i still don't know why the setting can cause the problem.

    Conclusion: Change the "Printf formatter" to 'small', the function in app_at.c would work well.


    I guess the reason that the function work well in light_switch.c maybe is this: my light_switch.c print the 'int16 rssi', the func is suit to the "Printf formatter" setting 'medium' and work well. When the func is put to other .c, it maybe is optimized, so work error.

    Does anybody know the exactly reason? now i used IAR 8.10.1.

  • There is a good news, i got the point.

    The default BasicRf stack size setting is too small, which the idata 0x40 xdata 0x100.
    when i enlarge the stack size, the project with 'medium'printf formatter can also work, so it's this.

    Hope this topic is useful for others using BasicRF.
  • It is good that you found a resolution. However I would check your code above, before you set g_at to true there is an if statement that returns if it is true. It looks like you assume it is initialised to false (or 0 which is likely the case, but dangerous to assume).

    Regards, TC.