Hi friends,
I trying to build library for DHT11 sensor for this I written API for 1 microsecond delay with help of energia
void delayMicroseconds(unsigned int us)
{
int i=0;
// Systick timer rolls over every 1000000/SYSTICKHZ microseconds
if (us > (1000000UL / SYSTICKHZ - 1)) {
delay(us / 1000); // delay milliseconds
us = us % 1000; // handle remainder of delay
};
// 24 bit timer - mask off undefined bits
unsigned long startTime = HWREG(NVIC_ST_CURRENT) & NVIC_ST_CURRENT_M;
unsigned long ticks = (unsigned long)us * (F_CPU/1000000L);
volatile unsigned long elapsedTime;
if (ticks > startTime) {
ticks = (ticks + (NVIC_ST_CURRENT_M - (unsigned long)F_CPU / SYSTICKHZ)) & NVIC_ST_CURRENT_M;
}
do {
elapsedTime = (startTime-(HWREG(NVIC_ST_CURRENT) & NVIC_ST_CURRENT_M )) & NVIC_ST_CURRENT_M;
} while(elapsedTime <= ticks);
}
it is working in enegia, but I want same in Code Composer Studio. but I am getting infine loop at above line mention in RED color.
I always getting the value of elapsedTime is always zero.
Regards,
Arvind