TPU emulation mode

sinil boga <[email protected]> Thu, 13 Jul 2006 23:04:45 -0700 (PDT)
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
Hi  
   
  I have one doubt regarding TPU emulation mode.
   
  I have written simple microcode and successfully compiled by tpumasm.exe. I have code warrior compiler and MPC565 target board then how can I download it into the MPC565processor and TPU DPRAM.
   
   
   
  Thanks and regards
  Sinil B

Jean-Christophe MATHAE <[email protected]> wrote:
          Hello Sinil,

We use a TPU channel configured with the Output Capture function.

Here is the C++ code, which defines the TPUCOUNTEROVERFLOW class as derived from a TPU class not described here, but this should be enough to give you an idea of how it works...

////////////////////////////////////////////////////////////////////////

WORD TPUCOUNTEROVERFLOW::m_wMSW1Timer32 = 0, // incremented at half period
TPUCOUNTEROVERFLOW::m_wMSW2Timer32 = 0; // incremented at end of period

#ifdef _DEBUG
bool TPUCOUNTEROVERFLOW::m_bIsActivePresent = false;// 'true' if instanciation with interrupt enabled
#endif _DEBUG

TPUCOUNTEROVERFLOW::TPUCOUNTEROVERFLOW (const int iChannel,
const MODULE Module /*= A*/)
:TPU (iChannel, Module)
{
}

/* cFunction= TF_OC;
cPriority= TP_LOW;
cHSQ= 1; All code is executed OFFSET == $8000
cHSR= 1; Host-init pulse mode REF_ADDR1 == $F8 (REF_TIME)
cInterrupt= TRUE; REF_TIME == 0
cTBS= TO_TCR1; capture and match TCR1
cPAC= TE_FALL; Low on match (at $8000)
cPSC= TF_NONE; Do not force any state
*/
const MPC555::TPU::INIT TPUCOUNTEROVERFLOW::ctiOCInit = {
OC, LOW, 1, 1, true, TCR1_OUT, FALL, NOFORCE,
{0, 0x8000, 0x00F8, 0x0000, 0x0000, 0x0000} // Parameter RAM
};

void
TPUCOUNTEROVERFLOW::Init (const bool bInterrupt /*= true*/)
{
INIT tiOC = ctiOCInit;
tiOC.cHSQ= bInterrupt ? 1 : 3;
tiOC.bInterrupt= bInterrupt;
tiOC.awRAM [2]= (tiOC.awRAM [2] & 0x000F) | (m_iChannel << 4);
TPU::Init (&tiOC);

#ifdef _DEBUG
if (bInterrupt)
m_bIsActivePresent= true;
#endif _DEBUG
}

DWORD
TPUCOUNTEROVERFLOW::GetCurrentTime() const
{
ASSERT (not m_bitInterruptEnable.Test());

SetHostSequence (3);
Restart (1);
WaitReady();

return (GetTime (MPC555::InputW (((DWORD) &m_awRAM & 0xFFFF00) | 0x0000EC)));
}

void
TPUCOUNTEROVERFLOW::Interrupt()
{
ASSERT (m_bitInterruptEnable.Test());

//AcknowledgeInt(); Done in Restart() !

const WORD wTCR1 = ReadWord (5);
//static SPYARRAY<WORD, 0x100> spy;
//spy.Put (wTCR1);
if (wTCR1 < 0x8000U)
{
m_wMSW1Timer32= m_wMSW2Timer32;
WriteWord (0, ChannelControl (TCR1_OUT, FALL, NOFORCE)); // Reprogramme channel
}
else
{
m_wMSW2Timer32 ++;
WriteWord (0, ChannelControl (TCR1_OUT, RISE, NOFORCE)); // Reprogramme channel
}

Restart (1); // Restarts channel
}

////////////////////////////////////////////////////////////////////////

Hope this could help you.

Best regards.

Jean-Christophe MATHAE

CIRTEM
http://www.cirtem.com

bâtiment Pointe Bleue
20, voie l'Occitane
BP661
31319 LABEGE cedex
France


         

 		
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1¢/min.

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/dN_tlB/TM
--------------------------------------------------------------------~-> 

-----------------------------------------------------------
To learn more about Freescale Microcontrollers, please visit
http://www.freescale.com/mcu


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/MPC500/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/