PIC24 Support Libraries
Macros | Functions
pic24_delay.h File Reference
#include <stdint.h>
#include "pic24_util.h"
#include <libpic30.h>

Go to the source code of this file.

Macros

#define DELAY_MS(ms)   delayAndUpdateHeartbeatCount(CYCLES_PER_MS * ((uint32_t) (ms)));
 
#define DELAY_US(us)   delayAndUpdateHeartbeatCount(CYCLES_PER_US * ((uint32_t) (us)));
 

Functions

static void delayAndUpdateHeartbeatCount (uint32_t u32_cyc)
 

Detailed Description

Provides simple software delays. They are not cycle-accurate, however. These routines are integrated with a heartbeat LED, so the heartbeat count is updated during a delay.

Definition in file pic24_delay.h.

Macro Definition Documentation

◆ DELAY_MS

#define DELAY_MS (   ms)    delayAndUpdateHeartbeatCount(CYCLES_PER_MS * ((uint32_t) (ms)));

A macro to delay the given number of milliseconds. The maximum delay is ~ 100+ seconds when FCY = 40 MHz, because the underlying function delayAndUpdateHeartbeatCount uses a uint32_t value for the number of processor clocks to delay.

Parameters
msThe number of milliseconds to delay.

Definition at line 71 of file pic24_delay.h.

Referenced by configUART1().

◆ DELAY_US

#define DELAY_US (   us)    delayAndUpdateHeartbeatCount(CYCLES_PER_US * ((uint32_t) (us)));

A macro to delay the given number of microseconds.

See also
DELAY_MS for additional information.
Parameters
usThe number of microseconds to delay.

Definition at line 77 of file pic24_delay.h.

Function Documentation

◆ delayAndUpdateHeartbeatCount()

static void delayAndUpdateHeartbeatCount ( uint32_t  u32_cyc)
inlinestatic

Delay the given number of processor clock cycles, then notify the heartbeat that time passed. Scale the time added to the heartbeat because we are not incurring the same overhead as if we repeatedly called doHeartbeat().

Parameters
u32_cycNumber of processor clock cycles to delay.

Definition at line 55 of file pic24_delay.h.