This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Software delay problem???

Other Parts Discussed in Thread: MSP430F5438

I am having a problem creating a software delay to toggle a pin. The problem is the time of the software delay. I am using a MSP430F5438. MCLK should be ~1MHz. I count for 200 clock cycles which should be ~0.2ms. When I probe the pin the time delay is ~2ms. This would mean that MCLK would be 100kHz which doesn't make sense. The code is below. Does anyone know why this time delay would be off? 

 

#define DELAYLOOPS 200

volatile unsigned int count;

P1OUT |= BIT0;  // turn P1.0 high

for (count = 0; count < DELAYLOOPS; ++count) {

P1OUT &= ~BIT0; // turn P1.0 low

**Attention** This is a public forum