Added a delay function that would be able to be adjusted more easily; also used the _NOP() function instead of asm() since it is more easily found in the header files
This commit is contained in:
@@ -20,16 +20,24 @@
|
||||
|
||||
void clock_init(void);
|
||||
|
||||
static inline void delay(void)
|
||||
{
|
||||
static inline void delay(void){
|
||||
volatile int jj;
|
||||
volatile int ii;
|
||||
// Using count-down since it uses one less instruction to compare (not really necessary here, but CCS recommends it anyway): Ultra-Low Power Advisor > Rule 13.1 (https://software-dl.ti.com/ccs/esd/documents/dmed/HTML/MSP430/1544.html)
|
||||
for (ii = 4; ii > 0; ii--)
|
||||
{
|
||||
for (jj = 1000; jj > 0; jj--)
|
||||
{
|
||||
asm(" nop"); //The space is necessary or else the assembler thinks "nop" is a label!
|
||||
for (ii = 4; ii > 0; ii--){
|
||||
for (jj = 1000; jj > 0; jj--){
|
||||
_NOP();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void delayMultiplied(int multiplier){
|
||||
volatile int jj;
|
||||
volatile int ii;
|
||||
// Using count-down since it uses one less instruction to compare (not really necessary here, but CCS recommends it anyway): Ultra-Low Power Advisor > Rule 13.1 (https://software-dl.ti.com/ccs/esd/documents/dmed/HTML/MSP430/1544.html)
|
||||
for (ii = 4 * multiplier; ii > 0; ii--){
|
||||
for (jj = 1000; jj > 0; jj--){
|
||||
_NOP();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user