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.

CC2640R2F: Toggling pin with clock interrupt giving strange results

Part Number: CC2640R2F

I am trying to toggle a pin at a rate of 60 us. I know that Clock_tickPeriod is 10 us, so I want 6 ticks.

Clock setup:

  /* SCIO clock */
  Clock_Params scioClockParams;
  Clock_Params_init(&scioClockParams);
  scioClockParams.startFlag = TRUE;
  scioClockParams.period = 6;
  Clock_construct(&scioClock, scioSwiFxn, 0, &scioClockParams);

ISR:

static volatile int toggle = 0;
static void scioSwiFxn(UArg unused)
{
    toggle ^= 1;
    PIN_setOutputValue(ioPinHandle, Board_PIN_GPIO4, (uint32_t)toggle);
}

I expect a 60 us square wave on this pin, but instead I get this. The small pulse is 9.2 us, the large pulse in the middle is 166 us.

  • Hi,

    The "period resolution" is 10us but the RTC is the driving clock and that is fixed at ~31us / tick. Due to how the capture of the RTC works, the lowest "tick" value you could set is 4 RTC ticks, or 120 us (ish).  (this means that your "2 ticks" would be extended to 4 internally.

    On top of this, there is latency in the SWI posting which would add more jitter. Basically, using Clock to setup very fast timers is not the best approach. Typically, to generate quick interrupts you would need to use the GPTimer (or PWM driver if that fits your need) as this runs using the 48 MHz clock.