John Reynolds

CW 6.3 build 14 Lite optimization question

Discussion created by John Reynolds on Sep 26, 2007
Latest reply on Sep 27, 2007 by John Reynolds
Hi,
I started setting up the ADC on the M52233 and I'm using the ini code
generated by the Freescale init software that allows you to
plug in some params and it generates the C code to ini various
peripherals. While debugging in mixed view mode I noticed the
line

// Wait for converter A power up to complete
while (MCF_ADC_POWER & MCF_ADC_POWER_PSTS0)

would never fall through because the compiler was not re reading the
MCF_ADC_POWER reg. I changed the definition to make it volitale

#define MCF_ADC_POWER *(volatile unsigned short *)(MFC_ADC_ADD + 0x52) // ADC Power Control register

but it still wouldn't work. I had to change the CodeWarrior global
optimization from 4, generate smallest code, to 2 to get it to
work.
I see where various regs in M5223x.h are using the volatile keyword
and it works with full optimization. Why do I have to lower it
to get the ADC loop to work ?


Thanks,
John

--
Alban Edit: format changed to allow text wrapping


Message Edited by Alban on 2007-10-01 08:50 PM

Outcomes