Re: TPU Problem

"spw_lotus" <[email protected]>
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
Hi Eric

Many, many thanks for your reply. It's nice to know that experts like 
you are around to give us newbies some help.

I have implemented your comments but still the TPU 'hangs'.

I note your comment about the link channel code, originally I was 
attempting to run this function on channel 3 and linking to a 
different function on channel 1, hence the extra (commented out) code.

I have also now negated all three latches at the end of phase. 

As you stated the END_OF_LINK is as per your comment.

If you don't mind I will attach my 'C' source code for the program I 
am running. Note that this board is running on an Axiom PB-0555 board 
therefore all of the relevant CPU registers have been initialised by 
the monitor program. As you will see from my program I have inserted 
a number of checks of TPU register values but they all seem to be as 
expected.

I really can't see why it doesn't work...hopefully someone else can!!

Please note that at present I don't have any development tools. So I 
have no way of debugging apart from well positioned print functions. 
I hope to purchase the full Ashware simulator and some debugger 
hardware for the CPU (and hopefully the TPU) if I can be happy that 
this device is suitable for my purposes. 

Many thanks again for your help.

Best regards

Steve Wiggins


CODE FOLLOWS:

#include "diab.h"
#include "serial.h"
#include "mpc555.h"
#include "tpu_pwm.h"
#include "mpc500_util.h"
#include "mpc500_util.c"

void delay();

struct TPU3_tag *tpua = &TPU_A;   /* pointer for TPU routines */

UINT8 sqw_chan = 0;
UINT8 meas_chan = 1;
UINT16 tempValue;

UINT8 *ptrDest = (UINT8 *)0x302000;
unsigned char myString[100];

const UINT8 acTPUROM [0x800] = {
#include "hexout.txt"
};

/************** TPU Set up **************/
/* Set up the TPU....                      */
void setup_tpu(struct TPU3_tag *tpu)
{
//     tpu->TPUMCR.R = 0x2020; /* TCR1 prescaler divide by 2, 
supervisor and user acces. */
	tpu->TPUMCR.R = 0x2400; /* TCR1 prescaler divide by 2, 
supervisor and user acces.  changed run in TPU 1 Mode and emulation 
mode*/
	tpu->TPUMCR3.R = 0x0040; /* enable enhanced prescaler - 
divide by 2 */
}


main(){
	char choice;
	int i=0;
	UINT8 myData;
	
	
	delay();	// delay in case hardware needs time

	InitCom(0);	// initialize SCI1 serial port 1
	ioport = 0;	// default to 0 for now, don't detect.

	delay();	// delay in case hardware needs time

	for(i=0; i<0x800; i++)
	{
		myData = acTPUROM[i];
		*ptrDest = myData;
//		sprintf(myString,",%02x ", myData);
//		puts(myString);
		ptrDest++;
	}
	sprintf(myString,"\n\nTPU Functions Written\n");
	puts(myString);
	
	// check TPUMCR value before configuration
	tempValue = tpua->TPUMCR.R;
	sprintf(myString,"\n\nTPU MCR = %0x\n", tempValue);
	puts(myString);
		
	setup_tpu(tpua); /* Do general TPU set up. */
	
	// check TPUMCR value after configuration
	tempValue = tpua->TPUMCR.R;
	sprintf(myString,"\n\nTPU MCR = %0x\n", tempValue);
	puts(myString);


    tpu_disable( tpua, sqw_chan);
	tpu_disable( tpua, meas_chan);
    
    /* SQW is function 14                  */
    tpu_func( tpua, sqw_chan, 0x0e);

    /* disable interupts on channels so they can be configured safely 
*/
    tpu_interrupt_disable( tpua, sqw_chan );
	tpu_interrupt_disable( tpua, meas_chan );


	tpua->PARM.R[sqw_chan][0] = 0x7000;
    tpua->PARM.R[sqw_chan][2] = 0x0002;

	tpu_hsr(tpua, sqw_chan, 0x03);
    tpu_enable(tpua, sqw_chan, TPU_PRIORITY_HIGH);
	delay();
	
    tpu_func( tpua, meas_chan, 0x0f);

	tempValue = tpua->CFSR3.R;
	sprintf(myString,"\n\nCFSR3 = %04x\n", tempValue);
	puts(myString);

	tempValue = tpua->CPR1.R;
	sprintf(myString,"\n\nCPR1 = %04x\n", tempValue);
	puts(myString);

	for(; ;){
		choice = tolower(GetSByte());
		i++;
		if(i % 2)
		{
			puts("\nEnable Measure Func");
			tpu_hsr(tpua, meas_chan, 0x03);
			tpu_enable(tpua, meas_chan, TPU_PRIORITY_LOW);
		}
		else
		{
			puts("\nDisable Measure Func");
			tpu_disable(tpua, meas_chan);
		}
		// display values of CPR1 & CFSR3 Registers
		tempValue = tpua->CPR1.R;
		sprintf(myString,"\n\nCPR1 = %04x\n", tempValue);
		puts(myString);
		tempValue = tpua->CFSR3.R;
		sprintf(myString,"CFSR3 = %04x\n", tempValue);
		puts(myString);
	}
}

void delay(){
	unsigned long delaycount;

	delaycount=0;
	do{
		delaycount++;
	}while(delaycount < 1000);
}




--- In [email protected], Eric McRae <eric@e...> wrote:
> Your link code (which is commented out) is running on channel 1 and 
is 
> also asserting a link to channel 1 so be careful if you enable that.
> 
> I think you may also be leaving yourself open to a match occurring 
due 
> to whatever hardware state existed before starting this function.  
If a 
> match does occur, the TPU will spin on calling TRANS_MES since MRL 
is 
> not negated there.  Still, that shouldn't prevent channel 0 from 
running.
> 
> BTW, zeroing the priority of a function only prevents it from 
starting 
> but will not stop a function if it happens to already be running.
> 
> It looks like your transition detection function shouldn't run 
forever.  
> My first suspicion is that the configuration registers aren't set 
up 
> correctly for channel 1.  Typically, the only way a normally 
running 
> channel ceases to function is when a function on another channel 
> clobbers the normal channel's data or that other function never 
releases 
> the TPU Engine by hitting an end instruction.  You don't show 
> END_OF_LINK but I presume it is a "chan neg_lsl; end"  Take a look 
at 
> the scheduler registers if you can they may tell you something.




-----------------------------------------------------------
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.