Skip to content

Instantly share code, notes, and snippets.

@ksvbka
Created May 10, 2015 09:36
Show Gist options
  • Save ksvbka/d223e9b7f1d9449880f3 to your computer and use it in GitHub Desktop.
Save ksvbka/d223e9b7f1d9449880f3 to your computer and use it in GitHub Desktop.
Define marco for delay
#ifndef DELAY_H
#define DELAY_H
#include msp430g2553.h
#ifndef F_CPU
#warning F_CPU not defined for <delay.h>. Using default
#define F_CPU 1000000UL // 1 MHz
#endif
#if !(F_CPU)
#error "F_CPU must be a constant value"
#endif
#define _delay_ms(ms) __delay_cycles((F_CPU*ms)/1000UL)
#define _delay_us(us) __delay_cycles((F_CPU*us)/1000000UL)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment