267
; Initialize the T1 module
T1INIT MOV #04Eh,T1CM ;Set up the T1 compare register to contain
MOV #020h,T1CL ; (4E20h). PWM frequency = 250 Hz. (The
; actual frequency is not very important
; But should be > 100 Hz.)
; Must load MSB first then LSB.
MOV HIDUTY,T1CCM ;Load value for the duty cycle.
MOV LODUTY,T1CCL ; Must load MSB first then LSB.
MOV #0,T1PC1 ;T1EVT pin is set as a general-purpose
; input.
MOV #0,T1PRI ;Set the T1 interrupt priority to level 1.
MOV #01110000b,T1CTL4 ;Select dual compare mode, enable toggle
; function of compare registers 1 and 2,
; and reset T1 on compare 1 equal.
MOV #00000000b,T1CTL1 ;Select system clock as timer clock source.
MOV #00000001b,T1CTL2 ;Reset the counter (could enable WD here).
MOV #00000000b,T1CTL3 ;Clear and disable all interrupts.
MOV #00100000b,T1PC2 ;Enable T1PWM (Initial output value (0)
; selected by bit 6), T1IC/CR is general–
; purpose input.
EINT ;Enable interrupts.
MAIN ... ;Begin main program loop here.
...
; In this example, the main program checks the values of the
; MS/LSDATA register pair against the HI/LODUTY register pair. If the
; values are different, the PWM duty cycle needs to be changed. The
; main loop also checks to see if any new value is between 0% and
; 100%. If so, the T1INT service is entered. If the new value is
; 0% or 100% exactly, the T1PWM pin is set to a general-purpose
; output pin, with the data value of 0 (0%) or 1 (100%).
CHKSAME CMP MSDATA,HIDUTY ;Check to see if the new reading in MSDATA
JNE UPDATE ; equals HIDUTY. If not, jump to UPDATE.
CMP LSDATA,LODUTY ;If so, check to see if new reading in
JEQ SAMEVALU ; LSDATA equals LSDUTY. If value is same
; as last time, no need to update
; HI/LODUTY. If not, go to UPDATE.
; The values in the MS/LSDATA registers are not equal to the
; HI/LODUTY values, therefore the HI/LODUTY registers need to be
; updated.
UPDATE MOVW LSDATA,LODUTY ;A new value has been read and stored in
SBIT1 NEWVALUE ; the HIDUTY/LODUTY register pair.
JMP ONWARD ; Set NEWVALUE then jump to ONWARD.
; The values in the MS/LSDATA registers are equal to the HI/LODUTY
; values. No update of the HI/LODUTY registers is required.
SAMEVALU SBIT0 NEWVALUE ;The value read from MS/LSDATA equals
; HI/LODUTY. Clear NEWVALUE.
*
Summary of Contents for TMS370 Series
Page 1: ...TMS370 Microcontroller Family Application Book 1996 8 Bit Microcontroller Family ...
Page 2: ...Printed in U S A February 1996 SPNA017 ...
Page 3: ...1996 Application TMS370 Microcontroller Family Book ...
Page 20: ...1 Part I Introduction ...
Page 21: ...2 ...
Page 22: ...3 Introduction Microcontroller Products Semiconductor Group Texas Instruments ...
Page 23: ...4 ...
Page 25: ...6 ...
Page 27: ...8 ...
Page 29: ...10 ...
Page 31: ...12 ...
Page 33: ...14 ...
Page 37: ...18 ...
Page 39: ...20 ...
Page 41: ...22 ...
Page 43: ...24 ...
Page 45: ...26 ...
Page 47: ...28 ...
Page 49: ...30 ...
Page 81: ...62 ...
Page 82: ...63 Clear RAM Microcontroller Products Semiconductor Group Texas Instruments ...
Page 83: ...64 ...
Page 85: ...66 ...
Page 86: ...67 RAM Self Test on the TMS370 Microcontroller Products Semiconductor Group Texas Instruments ...
Page 87: ...68 ...
Page 89: ...70 ...
Page 90: ...71 ROM Checksum on the TMS370 Microcontroller Products Semiconductor Group Texas Instruments ...
Page 91: ...72 ...
Page 95: ...76 ...
Page 97: ...78 ...
Page 98: ...79 Bubble Sort With the TMS370 Microcontroller Products Semiconductor Group Texas Instruments ...
Page 99: ...80 ...
Page 101: ...82 ...
Page 103: ...84 ...
Page 105: ...86 ...
Page 109: ...90 ...
Page 115: ...96 ...
Page 117: ...98 ...
Page 119: ...100 ...
Page 121: ...102 ...
Page 125: ...106 ...
Page 127: ...108 ...
Page 207: ...188 ...
Page 209: ...190 ...
Page 211: ...192 ...
Page 213: ...194 ...
Page 219: ...200 ...
Page 221: ...202 ...
Page 313: ...294 ...
Page 315: ...296 ...
Page 319: ...300 ...
Page 323: ...304 ...
Page 324: ...305 T1PWM Set Up Routines Microcontroller Products Semiconductor Group Texas Instruments ...
Page 325: ...306 ...
Page 327: ...308 ...
Page 329: ...310 ...
Page 331: ...312 ...
Page 387: ...368 ...
Page 389: ...370 ...
Page 393: ...374 ...
Page 395: ...376 ...
Page 396: ...377 PACT Command Macros Microcontroller Products Semiconductor Group Texas Instruments ...
Page 397: ...378 ...
Page 403: ...384 ...
Page 405: ...386 ...
Page 459: ...440 ...
Page 461: ...442 ...
Page 467: ...448 ...
Page 469: ...450 ...
Page 471: ...452 ...
Page 475: ...456 ...
Page 477: ...458 ...
Page 479: ...460 ...
Page 483: ...464 ...
Page 485: ...466 ...
Page 487: ...468 ...
Page 491: ...472 ...
Page 492: ...473 Part V External Memory Expansion Examples ...
Page 493: ...474 ...
Page 495: ...476 ...
Page 497: ...478 ...
Page 499: ...480 ...
Page 513: ...494 ...
Page 515: ...496 ...
Page 521: ...502 ...
Page 523: ...504 ...
Page 525: ...506 ...
Page 545: ...526 ...
Page 547: ...528 ...