CPM command processing
Leon Pollak
leonp at plris.com
Mon Jan 14 07:53:12 UTC 2008
My code is as following:
#define WAIT_LOOPS 200
void DoCommandCPM(int Command, int Channel) {
volatile int i, lvl;
rtems_interrupt_disable(lvl);
for(i = 0; i < WAIT_LOOPS; i++)
if (!(CPU->CP_CR & CP_CMND_FLAG)) break;
if (i == WAIT_LOOPS)
MsgFatal("CmndCPM ");
CPU->CP_CR = CP_CMND_FLAG | Command | Channel;
//The UM states that CPM needs 120 cycles.
for(i = 0; i < WAIT_LOOPS; i++)
if (!(CPU->CP_CR & CP_CMND_FLAG)) break;
if (i == WAIT_LOOPS)
MsgFatal("CmndCPM ");
rtems_interrupt_enable (lvl);
}
On Monday, 14 בJanuary 2008, you wrote:
> My usual 2-cents:
>
> Busy-waiting with interrupts disabled is evil.
> Such a loop *must* IMHO implement a timeout
> so that the worst-case impact on latency other
> tasks have to suffer from is guaranteed.
>
> -- Till
>
> Leon Pollak wrote:
> > Hello, all.
> >
> > Both files
> > ..lib/libcpu/powerpc/mpc8260/cp.c
> > ..lib/libcpu/powerpc/mpc860/cp.c
> > contain the same code:
> >
> > void m8xx_cp_execute_cmd( uint32_t command )
> > {
> > uint16_t lvl;
> >
> > rtems_interrupt_disable(lvl);
> > while (m8260.cpcr & M8260_CR_FLG) {
> > continue;
> > }
> >
> > m8260.cpcr = command | M8260_CR_FLG;
> > rtems_interrupt_enable (lvl);
> > }
> >
> > The problem with this code is (based on my experience with both CPU's)
> > that it does not check the result of a command execution. Although
> > Motorola's specification states that CPM should finish the command
> > processing in about 20 cycles, my 13 years experience shows that there
> > are cases when the command is not executed and the flag bit remains "1".
> >
> > Therefore, I swap the operators in my code:
> >
> > m8260.cpcr = command | M8260_CR_FLG;
> >
> > while (m8260.cpcr & M8260_CR_FLG) {
> > continue;
> > }
> >
> > and cause system reset if it remains "1" for too long.
> >
> > I have no explanation to this, because after reset the system returns to
> > the same exactly sequence and now it passes. We have such problem once on
> > each 20-25 units based on MPC8260, but I remember this to occur on MPC860
> > units too.
> >
> > Hope this will be useful...
--
Dr.Leon M.Pollak
Director
PLR Information Systems Ltd.
Tel.:+972-98657670 | POB 8130, H'Aomanut 9,
Fax.:+972-98657621 | Poleg Industrial Zone,
Mob.:+972-544739246 | Netanya, 42160, Israel.
More information about the users
mailing list