Code: Select all
static void squareWave(void *arg)
{
/* PB0 will be used for square wave
use AlternateFunction.0 for digital io
*/
palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATE(0));
palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL);
while(true)
{
palSetPad(GPIOB, 0);
chThdSleepMicroseconds(1);
palClearPad(GPIOB, 0);
chThdSleepMicroseconds(1);
}
}
But the result is 10 kHz or so. What do we do wrong?
Edit
if `#define CH_CFG_ST_FREQUENCY 10000` remains in `chconf.h`, it does produce a 10 kHz output. When we change that value from 10000 to 1000000, it gives just about 100 kHz (99.8 kHz or so), but not 500 kHz. Also,