BlueNRG-1 and delay_ms() for OneWire read
Hi all,
I'm trying to create a project to read a temperature sound like a DS18B20. The problem is that I need a precise and stable delay time. Using Systick isn't possible because there's a conflict when using BLE. I tried using an MFT, but I can't create a function to vary the delay. I based my approach on a timer in MFT_Mode1 and a prescaler 80-1 on the 16MHz oscillator.
static inline void delay_us(uint32_t us) {
uint32_t ticks = us / 10; // 1 tick ≈ 10 µs
if (ticks == 0) ticks = 1;
uint16_t start = MFT_GetCounter2(MFT1);
while ((uint16_t)(MFT_GetCounter2(MFT1) - start) < ticks) {
}
}
static void MFT1_Reset(void) {
MFT_SetCounter2(MFT1,0);
}
static uint16_t MFT1_Get(void) {
return MFT_GetCounter2(MFT1);
Even if I vary my e.g. delay_us(2500) , I still get pulses at 10µs.
For test in loop
/* Start MFT timers */
MFT_Cmd(MFT1, ENABLE);
while (1) {
GPIO_SetBits(GPIO_Pin_6);
delay_us(250000); // 250 ms
GPIO_ResetBits(GPIO_Pin_6);
delay_us(250000);
}Thank for help
