Page 1
Advance Information TM57PA20/ TM57PA40 8 Bit Microcontroller User Manual Tenx reserves the right to change or discontinue this product without notice. tenx technology inc. tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Interrupts: Three pin interrupts, Timer0/Timer1 interrupt and Wakeup Timer interrupt Power Down mode support Package Types: 8 DIP/SOP, 16 DIP/SOP/SSOP, 20 DIP/SOP/SSOP DEVICE OTP ROM TTP™ function Note TM57PA40 4K x 14 bits Available TM57PA20 2K x 14 bits Not Available tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 6
BUZZER output Instruction cycle clock divided by N output. Where N is 1,2,4,8. The instruction TCOUT clock frequency is system clock frequency divided by two. PWM0/PWM1 10-bit PWM output ADC7~0 A/D converter input tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
F-Plane is bit-addressable, while the second half of F-Plane is not bit-addressable. R-Plane F-Plane Bit Addressable MOVWR Instruction Write Only Bit Addressable RAMBANK=0 RAMBANK=1 Bit Addressable Bit Addressable RAMBANK=0 RAMBANK=1 tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
C: Carry Flag or Borrow Flag ADD instruction SUB instruction 1: a carry occurred from the MSB 1: no borrow 0: no carry 0: a borrow occurred from the MSB tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
The interrupt event is level trigged. F/W must clear the interrupt event register while serves the interrupt routine. Interrupt Source Interrupt Pending Interrupt i-Flag Vector Interrupt Enable tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
2.3 PROM Re-use The PROM size of TM57PA40 is 4K words. For some F/W program, the program size could be less than 2K words. To fully utilize the PROM, the device allows users to reuse the PROM. This feature is named as Two Time Programmable (TTP) ROM.
(WDTE=1), the WDT generates the chip reset signal, even in sleep mode, otherwise, the WKT only generates overflow time out interrupt. If WDTE=0 and WKTIE=0 (Wakeup interrupt disable), the internal RC Timer stops for power saving. tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
T0I input. The Timer0 increase rate is determined by “Timer0 Pre- Scale” (TM0PSC) register in R-Plane. The Timer0 can generate interrupt (TM0I) when it rolls over. tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
The Timer1 increase rate is determined by “Timer1 Pre- Scale” (TM1PSC) register in R-Plane. The Timer1 can generate interrupt (TM1I) and T1OUT toggle signal when it rolls over. tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 15
8-bit MSB of PWM duty register (PWMDUTY). When the base counter rolls over, the 2-bit LSB of PWM duty register decide whether to set the PWM output signal high immediately or set it high after one clock cycle delay. tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 16
Advance Information UM-TM57PA20&40_E 8 Bit Microcontroller PWM example code: movlw 01111111b movwf ;set PWM0DUTY[9:2]=8’b01111111 movlw 11000000b movwf ;set PWM0DUTY[1:0]=2’b11 movlw 01000000b movwr ;enable PWM0 output to PA0 (PWM0_OUT) movlw movwr ;disable PWM0 (PWM0_OUT) tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
In external RC mode, the external resistor and capacitor determine the oscillation frequency. In the internal RC mode, the on chip oscillator generates 4MHz system clock. External Oscillator Circuit External RC Oscillator (Crystal or Ceramic) tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
PA3-6, nPAPU=0 Drive Drive Drive Drive Drive 4.3 PA7 PA7 can be only used in Schmitt-trigger input mode. The pull-up resistor is always connected to this pin. tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
- ADC conversion result ADCQ[11:4] ADCDQ 11.7~4 - ADC conversion result ADCQ[3:0] - H/W clear this bit after ADC end of conversion ADCSTART 11.3 0 S/W set this bit to start ADC conversion tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
1: the pin pull up resistor is disable 0: disable BUZZER output to PD1 pin BUZ_OUT 0b.7 1: enable BUZZER output to PD1 pin 0: disable PWM0 output to PA0 pin PWM0_OUT 0b.6 1: enable PWM0 output to PA0 pin tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 27
0 Test mode register, for manufacturer only, user do not write it Each bit controls its corresponding ADC7~0 enable pin, if the bit is nADC_IE 12.7~0 0: the corresponding pin is ADC input 1: the corresponding pin is digital input tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
1 : Register file Working Register Zero Flag Carry Flag Decimal Carry Flag Program Counter Top Of Stack Global Interrupt Enable Flag (i-Flag) Option Field Contents Bit Field Before After ← Assign direction tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 29
RETLW 01 1000 kkkk kkkk Return with Literal in W Go into standby mode, Clock SLEEP 00 0000 0000 0011 TO,PD oscillation stops XORLW 01 1111 kkkk kkkk XOR Literal "k" with W tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 30
If ’d’ is 1, the result is stored back in register ’f’. Cycle Example ANDWF FSR, 1 B : W = 0x17, FSR = 0xC2 A : W = 0x17, FSR = 0x02 tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 31
2nd cycle instruction. Cycle Example LABEL1 BTFSS FLAG, 1 B : PC = LABEL1 TRUE GOTO SUB1 A : if FLAG.1 = 0, PC = TRUE FALSE ... if FLAG.1 = 1, PC = FALSE tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 32
WDT/WKT Timer ← 00h Status Affected TO, PD OP-Code 00 0000 0000 0100 Description CLRWDT instruction clears the Watchdog/Wakeup Timer Cycle Example CLRWDT B : WDT counter = ? A : WDT counter = 0x00 tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 33
GOTO is an unconditional branch. The 12-bit immediate value is loaded into PC bits <11:0>. GOTO is a two-cycle instruction. Cycle Example LABEL1 GOTO SUB1 B : PC = LABEL1 A : PC = SUB1 tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 34
W register. If ’d’ is 1, the result is placed back in register ’f’. Cycle Example IORWF RESULT, 0 B : RESULT = 0x13, W = 0x91 A : RESULT = 0x13, W = 0x93, Z = 0 tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 35
00 0000 00rr rrrr Description Move data from W register to register ‘r’. Cycle Example MOVWR REG1 B : REG1 = 0xFF, W = 0x4F A : REG1 = 0x4F, W = 0x4F tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 36
Return from subroutine. The stack is POPed and the top of the stack (TOS) is loaded into the program counter. This is a two-cycle instruction. Cycle Example RETURN A : PC = TOS tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 37
SLEEP Go into standby mode, Clock oscillation stops Syntax SLEEP Operands Operation Status Affected TO, PD OP-Code 00 0000 0000 0011 Description Go into SLEEP mode with the oscillator stopped. Cycle Example SLEEP tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 38
If the content of register ‘f’ is 0, Zero flag is set to 1. Cycle Example TESTZ REG1 B : REG1 = 0, Z = ? A : REG1 = 0, Z = 1 tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Page 39
W register. If ‘d’ is 1, the result is stored back in register ‘f’. Cycle Example XORWF REG 1 B : REG = 0xAF, W = 0xB5 A : REG = 0x1A, W = 0xB5 tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
System Clock > LVR – = 3 V Frequency = 2.2 V = 0 V = 5 V Ports A/B/D = 3 V Pull-Up Resistor = 0 V = 5 V = 3 V tenx technology, inc. Preliminary Rev 1.3, 2009/10/19...
Advance Information UM-TM57PA20&40_E 8 Bit Microcontroller PACKAGING INFORMATION The order information: “IC Type” “XX” “YY” “C” “Z”. 1. “IC TYPE”: TM57PA20 / TM57PA40 2. “XX”: Package Type • DIP Code: D • SOP Code: S • SSOP Code: SS 3. “YY”: IC Pin Number •...
Need help?
Do you have a question about the TM57PA40 and is the answer not in the manual?
Questions and answers