Yahoo Groups archive

68300

Index last updated: 2026-04-29 00:01 UTC

Message

Re: The TPU

2002-07-09 by scandle34

I used the TPU2 in the '916Y3.
I nearly went batty because the chip I was using had a defective TPU!
Here is a square wave function with some testing code added.
Besides toggling pins, this also periodically places numbers in 
unused prm locations, so there are footprints of TPU execution when 
you pause the MCU in BDM mode...

I can also post the '916Y3 initialization code if it will help.


(*********************************************************************
*)
(* TPUawdt.UC                                                         
*)
(* Master file for awdt 916y3 eprom.                                  
*)
(* *** MUST be /srectype 2 for PEMICRO programmer!                    
*)
(*********************************************************************
*)
%type tpu2,512.
%org 0.

End_of_phase:                    end.
End_of_link:     chan neg_lsl;   end.
(*********************************************************************
*)
(* Function:    SQW2 -   SQUARE WAVE                                  
*)
(* Creation Date: 26/Sep/01                 From: SQW                 
*)
(* Author:  Jeffrey C. Andle                                          
*)
(* Description:                                                       
*)
(* ------------                                                       
*)
(* SQW2 produces a continuous wave after initialization. The   	      
*)
(* user chooses the period by writing the parameters HIGH_TIME        
*)
(* and LOW_TIME in ram as prm0 and prm1.                              
*)
(* (High time and low time are NOT the same.)                         
*)
(* HIGH_TIME must be between $0000-$8000.                             
*)
(*                                                                    
*)
(* Updates:   By:   Modification:                                     
*)
(* --------   ---   -------------                                     
*)
(*--------------------------------------------------------------------
*)
(* Standard Exits Used:-   End_Of_Phase: N         End_Of_Link: Y     
*)
(* External Files included: NONE                                      
*)
(* CODE SIZE excluding standard exits = 1? LONG WORDS                 
*)
(*--------------------------------------------------------------------
*)
(*********************************************************************
*)
(*()()()()()()()()()()() DATA STRUCTURE ()()()()()()()()()()()()()()()
*)
(*                                                                    
*)
(* name:               Written By:            Location  Bits:         
*)
(* -----               -----------            ---------------         
*)
(* prm0                CPU                     Parameter0  0..15      
*)
(*                                             Low time of period.    
*)
(*                                             prm0 <= $8000          
*)
(* prm1                CPU                     Parameter1  0..15      
*)
(*                                             High time of period.   
*)
(*                                             prm0 <= $8000          
*)
(* prm2                TPU                     period as verification 
*)
(*                                                                    
*)
(* hsr1   hsr0         Action                                         
*)
(* ----   ----         ------                                         
*)
(*  1       1          Initialize continuous square wave              
*)
(*                     return PERIOD                                  
*)
(*                                                                    
*)
(* Links Accepted: NO              Links Generated: NO                
*)
(*                                                                    
*)
(* Interrupts Generated After:     No interrupts generated            
*)
(*()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
*)

(*====================================================================
*)
(*|||||||||||||||||||||  MICROCODE STARTS BELOW  
|||||||||||||||||||||*)
(*VVVVVVVVVVVVVVVVVVVVV--------------------------
VVVVVVVVVVVVVVVVVVVVV*)

(*********************************************************************
*)
(* ENTRY name:  INIT_SQW                                              
*)
(* STATE(S) ENTERED: S1                                               
*)
(* PRELOAD PARAMETER : prm1                                           
*)
(* ENTER WHEN : HSR = %11                                             
*)
(*                                                                    
*)
(* ACTION: set time base as TCR1, set pin high, and pac to toggle     
*)
(*         pin after each match.  Write the current time + the        
*)
(*         HIGH_TIME to the mer.  Negate latches.  Enable service     
*)
(*         requests.  Write prm2 = prm0 + prm1.                       
*)
(*********************************************************************
*)
%entry name = INIT_SQW; function = $F; start_address *; disable_match;
cond hsr1=1,hsr0=1,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <- prm1.

        chan    TBS:= out_m1_c1,         (* pin is output, use TCR1 *)
                PAC:= toggle,            (* toggle pin on match *)
                pin:= high,              (* initialize pin as high *)
                enable_mtsr.             (* enable m/tsr requests *)
					 (* format 3 command *)

	chan	match_gte.		 (* TPU2 format 5. *)


        au      ert:= tcr1+p;            (* write cur time + high 
time*)
        chan    write_mer,               (*  to mer *)
                neg_mrl,
		neg_tdl,
		neg_lsl;                (* negate latches *)
                end.                    (* end of S1 *)
				(* format 2  merges addition and 
chan*)

(*********************************************************************
*)
(* ENTRY name:  LOW_SQW                                               
*)
(* STATE(S) ENTERED: S2                                               
*)
(* PRELOAD PARAMETER : prm0                                           
*)
(* ENTER WHEN : HSR = %00 m/tsr=1 lsr=X flag0=X pin=0                 
*)
(*                                                                    
*)
(* ACTION: Write prm0 + last match time to mer, neg_mrl.              
*)
(*                                                                    
*)
(*********************************************************************
*)
%entry name = LOW_SQW; function = $F; start_address *; enable_match;
cond hsr1=0,hsr0=0,lsr=x,m/tsr=1,pin=0,flag0=x;
ram p <- prm0.

(* This code was tested and fails...*)
(* THIS entry is not called!            *)
	ram	diob <- prm1.
	au	diob := diob + p.
	ram	diob -> prm3.

        au      ert:= ert + p;           (* write last match + prm0  
*)
        chan    write_mer,               (* write to mer *)
                neg_mrl,
		neg_tdl,
		neg_lsl;     		 (* negate latches *)
                end.                     (* end of S2 *)
(*********************************************************************
*)
(* ENTRY name:  HIGH_SQW                                              
*)
(* STATE(S) ENTERED: S3                                               
*)
(* PRELOAD PARAMETER : prm1                                           
*)
(* ENTER WHEN : HSR = %00 m/tsr=1 lsr=X flag0=X pin=1                 
*)
(*                                                                    
*)
(* ACTION: Write prm1 + last match time to mer, neg_mrl.              
*)
(*                                                                    
*)
(*********************************************************************
*)
%entry name = HIGH_SQW; function = $F; start_address *; enable_match;
cond hsr1=0,hsr0=0,lsr=x,m/tsr=1,pin=1,flag0=x;
ram p <-prm1.

(* This code was tested and works...*)
(* THIS entry is called!            *)
	ram	diob <- prm0.
	au	diob := diob + p.
	ram	diob -> prm4.

        au      ert:= ert + p;           (* write last match + prm0  
*)
        chan    write_mer,               (* write to mer *)
                neg_mrl,
		neg_tdl,
		neg_lsl;                 (* negate latches *)
                end.                     (* end of S3 *)

(*********************************************************************
*)
(*                       UNUSED STATES                                
*)
(*********************************************************************
*)

%entry name = UNUSED_SQW; function = $F; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=1,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <-none.

%entry name = UNUSED_SQW; function = $F; start_address END_OF_LINK; 
enable_match;
cond hsr1=1,hsr0=0,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <-none.

%entry name = UNUSED_SQW; function = $F; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=0,lsr=1,m/tsr=0,pin=x,flag0=x;
ram p <-none.




(*********************************************************************
*)
(* Function:    high -   set pin 
high                                  *)
(* Creation Date: 26/Sep/01                 From: SQW                 
*)
(* Author:  Jeffrey C. Andle                                          
*)
(* Description:                                                       
*)
(* ------------                                                       
*)
(*                                                                    
*)
(* Updates:   By:   Modification:                                     
*)
(* --------   ---   -------------                                     
*)
(*--------------------------------------------------------------------
*)
(* Standard Exits Used:-   End_Of_Phase: N         End_Of_Link: Y     
*)
(* External Files included: NONE                                      
*)
(* CODE SIZE excluding standard exits = 1? LONG WORDS                 
*)
(*--------------------------------------------------------------------
*)
(*********************************************************************
*)
(*()()()()()()()()()()() DATA STRUCTURE ()()()()()()()()()()()()()()()
*)
(*                                                                    
*)
(* name:               Written By:            Location  Bits:         
*)
(* -----               -----------            ---------------         
*)
(* prm0                TPU                     Parameter0  0..15      
*)
(*                                             ert.    *)
(*                                                                    
*)
(* hsr1   hsr0         Action                                         
*)
(* ----   ----         ------                                         
*)
(*  1       1          Initialize continuous square wave              
*)
(*                     return PERIOD                                  
*)
(*                                                                    
*)
(* Links Accepted: NO              Links Generated: NO                
*)
(*                                                                    
*)
(* Interrupts Generated After:     No interrupts generated            
*)
(*()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
*)

(*====================================================================
*)
(*|||||||||||||||||||||  MICROCODE STARTS BELOW  
|||||||||||||||||||||*)
(*VVVVVVVVVVVVVVVVVVVVV--------------------------
VVVVVVVVVVVVVVVVVVVVV*)

(*********************************************************************
*)
(* ENTRY name:  
INIT_HIGH                                              *)
(* STATE(S) ENTERED: S1                                               
*)
(* PRELOAD PARAMETER : prm1                                           
*)
(* ENTER WHEN : HSR = %11                                             
*)
(*                                                                    
*)
(* ACTION: set time base as TCR1, set pin high, and pac to toggle     
*)
(*         pin after each match.  Write the current time + the        
*)
(*         HIGH_TIME to the mer.  Negate latches.  Enable service     
*)
(*         requests.  Write prm2 = prm0 + prm1.                       
*)
(*********************************************************************
*)
%entry name = INIT_HIGH; function = $E; start_address *; enable_match;
cond hsr1=1,hsr0=1,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <- none.

        chan    TBS:= out_m1_c1,         (* pin is output, use TCR1 *)
                PAC:= no_change,            (* toggle pin on match *)
                pin:= high,              (* initialize pin as high *)
                disable_mtsr.             (* enable m/tsr requests *)

(* This code is tested and ...*)
	au	diob := tcr1.
	ram	diob -> prm0.

        chan    neg_mrl, neg_tdl, neg_lsl;      (* negate latches *)
                end.                            (* end of S1 *)


(*********************************************************************
*)
(*                       UNUSED STATES                                
*)
(*********************************************************************
*)

%entry name = UNUSED_HIGH; function = $E; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=1,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <-none.

%entry name = UNUSED_HIGH; function = $E; start_address END_OF_LINK; 
enable_match;
cond hsr1=1,hsr0=0,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <-none.

%entry name = UNUSED_HIGH; function = $E; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=0,lsr=1,m/tsr=x,pin=x,flag0=x;
ram p <-none.

%entry name = UNUSED_HIGH; function = $E; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=0,lsr=0,m/tsr=1,pin=x,flag0=x;
ram p <-none.


(*********************************************************************
*)
(* Function:    low -   set pin low                                  
*)
(* Creation Date: 26/Sep/01                 From: SQW                 
*)
(* Author:  Jeffrey C. Andle                                          
*)
(* Description:                                                       
*)
(* ------------                                                       
*)
(*                                                                    
*)
(* Updates:   By:   Modification:                                     
*)
(* --------   ---   -------------                                     
*)
(*--------------------------------------------------------------------
*)
(* Standard Exits Used:-   End_Of_Phase: N         End_Of_Link: Y     
*)
(* External Files included: NONE                                      
*)
(* CODE SIZE excluding standard exits = 1? LONG WORDS                 
*)
(*--------------------------------------------------------------------
*)
(*********************************************************************
*)
(*()()()()()()()()()()() DATA STRUCTURE ()()()()()()()()()()()()()()()
*)
(*                                                                    
*)
(* name:               Written By:            Location  Bits:         
*)
(* -----               -----------            ---------------         
*)
(* prm0                TPU                     Parameter0  0..15      
*)
(*                                             ert.    *)
(*                                                                    
*)
(* hsr1   hsr0         Action                                         
*)
(* ----   ----         ------                                         
*)
(*  1       1          Initialize continuous square wave              
*)
(*                     return PERIOD                                  
*)
(*                                                                    
*)
(* Links Accepted: NO              Links Generated: NO                
*)
(*                                                                    
*)
(* Interrupts Generated After:     No interrupts generated            
*)
(*()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
*)

(*====================================================================
*)
(*|||||||||||||||||||||  MICROCODE STARTS BELOW  
|||||||||||||||||||||*)
(*VVVVVVVVVVVVVVVVVVVVV--------------------------
VVVVVVVVVVVVVVVVVVVVV*)

(*********************************************************************
*)
(* ENTRY name:  
INIT_HIGH                                              *)
(* STATE(S) ENTERED: S1                                               
*)
(* PRELOAD PARAMETER : prm1                                           
*)
(* ENTER WHEN : HSR = %11                                             
*)
(*                                                                    
*)
(* ACTION: set time base as TCR1, set pin high, and pac to toggle     
*)
(*         pin after each match.  Write the current time + the        
*)
(*         HIGH_TIME to the mer.  Negate latches.  Enable service     
*)
(*         requests.  Write prm2 = prm0 + prm1.                       
*)
(*********************************************************************
*)
%entry name = INIT_LOW; function = $D; start_address *; enable_match;
cond hsr1=1,hsr0=1,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <- none.

        chan    TBS:= out_m1_c1,         (* pin is output, use TCR1 *)
                PAC:= no_change,            (* toggle pin on match *)
                pin:= low,              (* initialize pin as high *)
                disable_mtsr.             (* enable m/tsr requests *)

(* This code is tested and ...*)
	au	diob := tcr1.
	ram	diob -> prm0.

        chan    neg_mrl, neg_tdl, neg_lsl;      (* negate latches *)
                end.                            (* end of S1 *)


(*********************************************************************
*)
(*                       UNUSED STATES                                
*)
(*********************************************************************
*)

%entry name = UNUSED_LOW; function = $D; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=1,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <-none.

%entry name = UNUSED_LOW; function = $D; start_address END_OF_LINK; 
enable_match;
cond hsr1=1,hsr0=0,lsr=x,m/tsr=x,pin=x,flag0=x;
ram p <-none.

%entry name = UNUSED_LOW; function = $D; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=0,lsr=1,m/tsr=x,pin=x,flag0=x;
ram p <-none.


%entry name = UNUSED_LOW; function = $D; start_address END_OF_LINK; 
enable_match;
cond hsr1=0,hsr0=0,lsr=0,m/tsr=1,pin=x,flag0=x;
ram p <-none.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.