Hello
I am using the MSP430 F1611 with the Crossworks Compiler.
The MCLK is 7.3728 MHz.
So when I use __delay_cycles(737280) i expected a delay of 100 ms.
Instead the delay is 273 ms (measured with the timer and the 32.768
kHz clock). Interrupts are switched off.
Did I understand something wrong here?
Best regards
MeistaK
__delay_cycles() problem
Started by ●October 28, 2008
Reply by ●October 28, 20082008-10-28
I checked the disassambly and found out some intresting things:
If the code only generates one loop everything is working fine ( until
about 20ms)
For 2 nested loops -> the result is always 3*t_expected - 27 ms
Is working:
__delay_cycles(147456); // wait 20 ms
MOV.W #0xbfff, R15
@223
SUB.W #1, R15
JNZ @223
NOP
Is not working:
__delay_cycles(221184); // wait 30 ms
MOV.W #0x5ffc, R14
MOV.W #3, R15
@221
SUB.W #1, R14
JNZ @221
SUB.W #1, R15
JNZ @221
JMP @222
@222
--- In m..., "meistak" wrote:
>
> Hello
>
> I am using the MSP430 F1611 with the Crossworks Compiler.
> The MCLK is 7.3728 MHz.
>
> So when I use __delay_cycles(737280) i expected a delay of 100 ms.
> Instead the delay is 273 ms (measured with the timer and the 32.768
> kHz clock). Interrupts are switched off.
> Did I understand something wrong here?
>
> Best regards
> MeistaK
>
If the code only generates one loop everything is working fine ( until
about 20ms)
For 2 nested loops -> the result is always 3*t_expected - 27 ms
Is working:
__delay_cycles(147456); // wait 20 ms
MOV.W #0xbfff, R15
@223
SUB.W #1, R15
JNZ @223
NOP
Is not working:
__delay_cycles(221184); // wait 30 ms
MOV.W #0x5ffc, R14
MOV.W #3, R15
@221
SUB.W #1, R14
JNZ @221
SUB.W #1, R15
JNZ @221
JMP @222
@222
--- In m..., "meistak" wrote:
>
> Hello
>
> I am using the MSP430 F1611 with the Crossworks Compiler.
> The MCLK is 7.3728 MHz.
>
> So when I use __delay_cycles(737280) i expected a delay of 100 ms.
> Instead the delay is 273 ms (measured with the timer and the 32.768
> kHz clock). Interrupts are switched off.
> Did I understand something wrong here?
>
> Best regards
> MeistaK
>
Reply by ●October 28, 20082008-10-28
Hi,
> I checked the disassambly and found out some intresting things:
>
> If the code only generates one loop everything is working fine ( until
> about 20ms)
>
> For 2 nested loops -> the result is always 3*t_expected - 27 ms
Yeah, I know. As I said in our ticketing system, I'm looking into it.
--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors
> I checked the disassambly and found out some intresting things:
>
> If the code only generates one loop everything is working fine ( until
> about 20ms)
>
> For 2 nested loops -> the result is always 3*t_expected - 27 ms
Yeah, I know. As I said in our ticketing system, I'm looking into it.
--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors