AT89C5131-S3SIL Atmel, AT89C5131-S3SIL Datasheet
![IC 8051 MCU FLASH 32K USB 52PLCC](/photos/12/13/121324/453-52-plcc_sml.jpg)
AT89C5131-S3SIL
Specifications of AT89C5131-S3SIL
Available stocks
Related parts for AT89C5131-S3SIL
AT89C5131-S3SIL Summary of contents
Page 1
... Low Power Voltage Range – 3.0V to 3.6V – Max Operating Current (at 40 MHz) – 100 µA Max Power-down Current • Industrial Temperature Range • Packages: PLCC52, VQFP64, MLF48, SO28 8-bit Flash Microcontroller with Full Speed USB Device AT89C5131 Rev. 4136B–USB–09/03 ...
Page 2
... Kbyte), 256 bytes of internal RAM, a 4-level interrupt system, two 16-bit timer/counters (T0/T1), a full duplex enhanced UART (EUART) and an on-chip oscillator. In addition, AT89C5131 has an on-chip expanded RAM of 1024 bytes (ERAM), a dual- data pointer, a 16-bit up/down Timer (T2), a Programmable Counter Array (PCA programmable LED current sources, a programmable hardware watchdog and a power-on reset ...
Page 3
... Flash 4Kx8 RAM + 256x8 BRG C51 CORE Parallel I/O Ports & Ext. Bus Timer 0 INT Ctrl Timer 1 Port 0Port 1 Port 2 Port 3 (2) (2) (2) (2) AT89C5131 (1) (1) (1) (1) (1) (1) (1) (1) ERAM 1Kx8 SPI PCA Timer2 TWI Key Watch Regu- USB Board Dog ...
Page 4
... Pinout Description Pinout AT89C5131 4 Figure 1. AT89C5131 52-pin PLCC Pinout P4.1/SDA 8 P2.3/A11 9 P2.4/A12 10 P2.5/A13 11 12 XTAL2 13 XTAL1 14 P2.6/A14 P2.7/A15 15 VDD 16 AVDD AVSS 19 20 P3.0/RxD P0.1/AD1 44 P0.2/AD2 43 RST 42 P0.3/AD3 41 VSS PLCC52 40 P0.4/AD4 39 P3.7/RD/LED3 38 P0.5/AD5 37 P0.6/AD6 36 P0.7/AD7 35 P3.6/WR/LED2 4136B–USB–09/03 ...
Page 5
... Figure 2. AT89C5131 64-pin VQFP Pinout P2.3/A11 3 P2.4/A12 4 P2.5/A13 5 XTAL2 6 XTAL1 7 P2.6/A14 8 P2.7/A15 9 VDD 10 AVDD AVSS P3.0/RxD AT89C5131 P0.1/AD1 45 P0.2/AD2 44 RST 43 P0.3/AD3 42 VSS 41 NC VQFP64 40 P0.4/AD4 39 P3.7/RD/LED3 38 P0.5/AD5 37 P0.6/AD6 36 P0.7/AD7 35 P3.6/WR/LED2 ...
Page 6
... AT89C5131 6 Figure 3. AT89C5131 48-pin MLF Pinout P4.1/SDA 1 P2.3/A11 2 P2.4/A12 3 4 P2.5/A13 5 XTAL2 6 XTAL1 7 P2.6/A14 P2.7/A15 8 VDD 9 AVDD 10 AVSS 11 12 P3.0/RxD Figure 4. AT89C5131 28-pin SO Pinout P1.5/CEX2/KIN5/MISO 1 P1.6/CEX3/KIN6/SCK 2 P1.7/CEX4/KIN7/MOSI 3 P4.0/SCL 4 P4.1/SDA 5 XTAL2 6 XTAL1 7 VDD 8 9 AVSS 10 P3.0/RxD 11 PLLF VREF P1.0/T2/KIN0 36 35 P0.1/AD1 34 P0.2/AD2 ...
Page 7
... Signals 4136B–USB–09/03 All the AT89C5131 signals are detailed by functionality on Table 1 through Table 12. Table 1. Keypad Interface Signal Description Signal Name Type Description Keypad Input Lines KIN[7:0) I Holding one of these pins high or low for 24 oscillator periods triggers a keypad interrupt if enabled. Held line is reported in the KBCON register. ...
Page 8
... AT89C5131 8 Table 4. Timer 0, Timer 1 and Timer 2 Signal Description (Continued) Signal Name Type Description Timer Counter 0 External Clock Input T0 I When Timer 0 operates as a counter, a falling edge on the T0 pin increments the count. Timer/Counter 1 External Clock Input T1 I When Timer 1 operates as a counter, a falling edge on the T1 pin increments the count ...
Page 9
... Receives the RC network of the PLL low pass filter. Table 10. USB Signal Description Signal Name Type Description D+ I/O USB Data + signal D- I/O USB Data - signal USB Reference Voltage VREF O Connect this pin to D+ using a 1.5 k AT89C5131 Alternate Function AD[7: KIN[7:0] T2 T2EX ECI CEX[4:0] A[15:8] LED[3:0] RxD TxD INT0 INT1 ...
Page 10
... AT89C5131 10 Table 11. System Signal Description Signal Name Type Description Multiplexed Address/Data LSB for external access AD[7:0] I/O Data LSB for Slave port access (used for 8-bit and 16-bit modes) Address Bus MSB for external access A[15:8] I/O Data MSB for Slave port access (used for 16-bit mode only) Read Signal Read signal asserted during external data memory read operation ...
Page 11
... The Vref output is in high impedance when the bit DETACH is set in the USBCON register. VREF O When the bit DETACH is reseted, In low-power chips, the Vref output voltage is equal to the AVDD input. In standard versions, the Vref output voltage is equal to the internal regulator output. AT89C5131 Alternate Function pull up ...
Page 12
... SFR Mapping AT89C5131 12 The Special Function Registers (SFRs) of the AT89C5131 fall into the following categories: • C51 core registers: ACC, B, DPH, DPL, PSW, SP • I/O port registers: P0, P1, P2, P3, P4 • Timer registers: T2CON, T2MOD, TCON, TH0, TH1, TH2, TMOD, TL0, TL1, TL2, RCAP2L, RCAP2H • ...
Page 13
... TL0 TL1 TH0 0000 0000 0000 0000 0000 0000 DPL DPH 0000 0000 0000 0000 2/A 3/B 4/C AT89C5131 5/D 6/E 7/F CCAP3H CCAP4H XXXX XXXX XXXX XXXX CCAP3L CCAP4L XXXX XXXX XXXX XXXX CCAPM3 CCAPM4 X000 0000 ...
Page 14
... AT89C5131 14 The Special Function Registers (SFRs) of the AT89C5131 fall into the following categories: Table 14. C51 Core SFRs Mnemonic Add Name ACC E0h Accumulator B F0h B Register Program Status PSW D0h Word Stack Pointer SP 81h LSB of SPX Data Pointer Low byte DPL 82h ...
Page 15
... Baud Rate Control 4136B–USB–09/ TF1 TR1 TF0 TR0 GATE1 C/T1# M11 M01 TF2 EXF2 RCLK TCLK FE/SM0 SM1 SM2 REN BRR AT89C5131 IE1 IT1 IE0 IT0 GATE0 C/T0# M10 M00 EXEN2 TR2 C/T2# CP/RL2# T2OE DCEN TB8 RB8 ...
Page 16
... Interrupt Priority Control High 0 IPL1 B2h Interrupt Priority Control Low 1 IPH1 B3h Interrupt Priority Control High 1 Table 21. PLL SFRs Mnemonic Add Name PLLCON A3h PLL Control PLLDIV A4h PLL Divider AT89C5131 CIDL WDTE ECOM0 CAPP0 ECOM1 CAPP1 ECOM2 CAPP2 ECOM3 CAPP3 ...
Page 17
... WUPCPU EORINT - - EWUPCPU EEORINT - - - - EPEN - - - DIR RXOUTB1 STALLRQ TXRDY - EP6RST EP5RST EP4RST - EP6INT EP5INT EP4INT - EP6INTE EP5INTE EP4INTE AT89C5131 KBF4 KBF3 KBF2 KBF1 KBE4 KBE3 KBE2 KBE1 KBLS4 KBLS3 KBLS2 KBLS1 STO SI AA CR1 SC1 SC0 - - SD4 SD3 SD2 SD1 ...
Page 18
... AUXR 8Eh Auxiliary Register 0 AUXR1 A2h Auxiliary Register 1 CKCON0 8Fh Clock Control 0 CKCON1 AFh Clock Control 1 LEDCON F1h LED Control FCON D1h Flash Control EECON D2h EEPROM Contol AT89C5131 FDAT7 FDAT6 FDAT5 FDAT4 BYCT7 BYCT6 BYCT5 BYCT4 - - - - FNUM7 FNUM6 FNUM5 FNUM4 ...
Page 19
... Phase Lock Loop (PLL). All the internal clocks to the peripherals and CPU core are gen- erated by this controller. The AT89C5131 X1 and X2 pins are the input and the output of a single-stage on-chip inverter (see Figure 5) that can be configured with off-chip components as a Pierce oscillator (see Figure 6). Value of capacitors and crystal characteristics are detailed in the section “ ...
Page 20
... AT89C5131 20 Figure 6. Crystal Connection VSS The AT89C5131 PLL is used to generate internal high frequency clock (the USB Clock) synchronized with an external low-frequency (the Peripheral Clock). The PLL clock is used to generate the USB interface clock. Figure 7 shows the internal structure of the PLL. The PFLD block is the Phase Frequency Comparator and Lock Detector. This block ...
Page 21
... The typical divider values are shown in Table 27. Table 27. Typical Divider Values Oscillator Frequency 3 MHz 6 MHz 8 MHz 12 MHz 16 MHz 18 MHz 20 MHz 24 MHz 32 MHz 40 MHz AT89C5131 PLL Programming Configure Dividers N3:0 = xxxxb R3:0 = xxxxb Enable PLL PLLEN = 1 PLL Locked? LOCK = 1? R+1 N+1 16 ...
Page 22
... Registers AT89C5131 22 Table 28. CKCON0 (S:8Fh) Clock Control Register WDX2 PCAX2 Bit Bit Number Mnemonic Description Reserved 7 - The value read from this bit is always 0. Do not set this bit. Watchdog Clock This control bit is validated when the CPU clock X2 is set. When X2 is low, ...
Page 23
... Set by hardware when PLL is locked. Clear by hardware when PLL is unlocked. Reset Value = 0000 0000b Table 31. PLLDIV (S:A4h) PLL Divider Register Bit Bit Number Mnemonic Description 7-4 R3:0 PLL R Divider Bits 3-0 N3:0 PLL N Divider Bits Reset Value = 0000 0000 AT89C5131 EXT48 PLLEN ...
Page 24
... Figure 10. Use of Dual Pointer 7 0 DPS AUXR1(A2H) AT89C5131 24 The additional data pointer can be used to speed up code execution and reduce code size. The dual DPTR structure is a way by which the chip will specify the address of an exter- nal data memory location. There are two 16-bit DPTR registers that address the external memory, and a single bit called DPS = AUXR1 ...
Page 25
... DPS is toggled in the proper sequence matters, not its actual value. In other words, the block move routine works the same whether DPS is ’0’ or ’1’ on entry. Observe that without the last instruction (INC AUXR1), the routine will exit with DPS in the opposite state. AT89C5131 25 ...
Page 26
... Access Memory Interface AT89C5131 26 The AT89C5131 implement 32 Kbytes of on-chip program/code memory. Figure 11 shows the split of internal and external program/code memory spaces depending on the product. The Flash memory increases EPROM and ROM functionality by in-circuit electrical era- sure and programming. Thanks to the internal charge pump, the high voltage needed for programming or erasing Flash cells is generated on-chip using the standard V age ...
Page 27
... This signal is active low during external code fetch or external code read (MOVC instruction). This section describes the bus cycles the AT89C5131 executes to fetch code (see Figure 13) in the external program/code memory. External memory cycle takes 6 CPU clock periods. This is equivalent to 12 oscillator clock periods in standard mode or 6 oscillator clock periods in X2 mode ...
Page 28
... FM0 Memory Architecture User Space Extra Row (XRow) Hardware Security Space Column Latches Overview of FM0 Operations Mapping of the Memory Space By default, the user space is accessed by MOVC instruction for read only. The column AT89C5131 28 7FFFh 32 Kbytes Flash Memory User Space FM0 0000h The Flash memory is made blocks (see Figure 14): 1 ...
Page 29
... The bit FBUSY in FCON register is used to indicate the status of programming. FBUSY is set when programming is in progress. The bit ENBOOT in AUXR1 register is used to choose between FM0 and FM1 mapped up to F800h. AT89C5131 FM0 Adressable Space User (0000h-FFFFh) Extra Row(FF80h-FFFFh) Hardware Security (0000h) ...
Page 30
... Loading the Column Latches Programming the Flash Spaces User AT89C5131 30 Any number of data from 1 byte to 128 bytes can be loaded in the column latches. This provides the capability to program the whole memory by byte, by page or by any number of bytes in a page. When programming is launched, an automatic erase of the locations loaded in the col- umn latches is first performed, then programming is effectively done ...
Page 31
... Launch the programming by writing the data sequence 52h followed by A2h in FCON register. The end of the programming indicated by the FBUSY flag cleared. • Enable the interrupts. Figure 16. Flash and Extra Row Programming Procedure AT89C5131 Flash Spaces Programming Column Latches Loading see Figure 15 Disable IT ...
Page 32
... Hardware Security AT89C5131 32 The following procedure is used to program the Hardware Security space and is sum- marized in Figure 17: • Set FPS and map Hardware byte (FCON = 0x0C) • Disable the interrupts. • Load DPTR at address 0000h. • Load Accumulator register with the data to load. ...
Page 33
... Figure 18: • Map the Hardware Security space by writing 04h in FCON register. • Read the byte in Accumulator by executing MOVC A, @A+DPTR with & DPTR = 0000h. Figure 18. Reading Procedure AT89C5131 Flash Spaces Reading Flash Spaces Mapping FCON = 00000xx0b Data Read DPTR = Address ACC = 0 ...
Page 34
... Registers AT89C5131 34 Table 36. FCON (S:D1h) Flash Control Register FPL3 FPL2 FPL1 Bit Bit Number Mnemonic Description Programming Launch Command Bits 7-4 FPL3:0 Write 5Xh followed by AXh to launch the programming according to FMOD1:0. (see Table 35.) Flash Map Program Space 3 FPS Set to map the column latch space in the data memory space. ...
Page 35
... EPROM programmer. The parallel programming method used by these devices is similar to that used by EPROM 87C51 but it is not identical and the commercially available programmers need to have support for the AT89C5131. The bootloader and the Application Programming Interface (API) routines are located in the Boot ROM ...
Page 36
... Software registers are in a special page of the Flash memory which can be accessed through the API or with the parallel programming modes. This page, called “Extra Flash Memory”, is not in the internal Flash program memory addressing space. The only hardware registers of the AT89C5131 is called Hardware Security Byte (HSB). Table 37. Hardware Security Byte (HSB ...
Page 37
... Commands issued by the parallel memory programmer. • Commands issued by the ISP software. • Calls of API issued by the application software. Several software registers are described in Table 39. AT89C5131 LB2 Protection Description U No program lock features enabled. MOVC instruction executed from external program memory is disabled from fetching code ...
Page 38
... See Table 41 Default value FCh – 1011 1000b – 0FFh – FFh – 58h Atmel C51 X2, Electrically D7h Erasable F7h AT89C5131 32 Kbyte FBh AT89C5131 16 Kbyte AT89C5131 32 Kbyte, EFh revision 0 AT89C5131 16 Kbyte, FFh revision LB1 and Table 41. 0 LB0 4136B–USB–09/03 ...
Page 39
... X: don’t care 4. WARNING: Security level 2 and 3 should only be programmed after Flash and code verification. AT89C5131 parts are delivered with the ISP boot in the Flash memory. After ISP or par- allel programming, the possible contents of the Flash memory are summarized in Figure 19: ...
Page 40
... Description Write Data in the Column Latches Programming Read Data AT89C5131 40 The 1-Kbyte on-chip EEPROM memory block is located at addresses 0000h to 03FFh of the ERAM memory space and is selected by setting control bits in the EECON register. A read in the EEPROM memory is done with a MOVX instruction. A physical write in the EEPROM memory is done in two steps: write data in the column latches and transfer of all data latches into an EEPROM memory row (programming) ...
Page 41
... Set to map the EEPROM space during MOVX instructions (Write in the column 1 EEE latches) Clear to map the ERAM space during MOVX. Programming Busy flag Set by hardware when programming is in progress. 0 EEBUSY Cleared by hardware when programming is done. Cannot be set or cleared by software. Reset Value = XXXX XX00b Not bit addressable AT89C5131 EEPL0 - - 1 0 EEE EEBUSY 41 ...
Page 42
... With the implementation of the User Space (FM0) and the Boot Space (FM1) in Flash technology the AT89C5131 allows the system engineer the development of applications with a very high level of flexibility. This flexibility is based on the possibility to alter the customer program at any stages of a product’s life: • ...
Page 43
... These Bytes are reserved for customer use read or modify these Bytes, the APIs are used. RESET BLJB == 0 ? ENBOOT = F400h Bootloader in FM1 AT89C5131 bit ENBOOT in AUXR1 Register Is Initialized with BLJB Inverted. Example, if BLJB=0, ENBOOT is set (=1) during reset, thus the bootloader is executed after the reset. 43 ...
Page 44
... During the first programming, the user can define a configuration on Port1 that will be recognized by the chip as the hardware conditions during a Reset. If this condition is met, the chip will start executing the bootloader at the end of the Reset. See a detailed description in the applicable Document. – Datasheet Bootloader USB AT89C5131. Default Value Address 58h 30h ...
Page 45
... The value read from this bit is indeterminate. 2-0 LB2:0 Lock Bits Default value after erasing chip: FFh Notes: 1. Only the 4 MSB bits can be access by software. 2. The 4 LSB bits can only be access by parallel mode. AT89C5131 OSCON0 - LB2 1 oscillator is configured to run from MHz ...
Page 46
... Part Number ERAM Size AT89C5131 1024 The AT89C5131 has on-chip data memory that is mapped into the following four sepa- rate segments. 1. The Lower 128 bytes of RAM (addresses 00h to 7Fh) are directly and indirectly addressable. 2. The Upper 128 bytes of RAM (addresses 80h to FFh) are indirectly addressable only ...
Page 47
... The stack pointer (SP) may be located anywhere in the 256 bytes RAM (lower and upper RAM) internal data memory. The stack may not be located in the ERAM. The M0 bit allows to stretch the ERAM timings set, the read and write pulses are extended from clock periods. This is useful to access external slow peripherals. AT89C5131 47 ...
Page 48
... AT89C5131 48 Table 46. AUXR Register AUXR - Auxiliary Register (8Eh DPU - M0 Bit Bit Number Mnemonic Description Disable Weak Pull Up 7 DPU Cleared to enabled weak pull up on standard Ports. Set to disable weak pull up on standard Ports. Reserved 6 - The value read from this bit is indeterminate. Do not set this bit ...
Page 49
... Timer 2 Auto-reload Mode 4136B–USB–09/03 The Timer 2 in the AT89C5131 is the standard C52 Timer 16-bit timer/counter: the count is maintained by two cascaded eight-bit timer registers, TH2 and TL2 controlled by T2CON (Table 47) and T2MOD (Table 48) registers. Timer 2 operation is similar to Timer 0 and Timer 1. C/T2 selects F (counter operation) as the timer clock input ...
Page 50
... Figure 23. Auto-reload Mode Up/Down Counter (DCEN = 1) F CLK PERIPH Programmable Clock Output AT89C5131 C/T2 T2CON (DOWN COUNTING RELOAD VALUE) FFh (8-bit) (8-bit) TL2 (8-bit) (8-bit) RCAP2L RCAP2H (8-bit) (UP COUNTING RELOAD VALUE) In the Clock-out mode, Timer 2 operates as a 50%-duty-cycle, programmable clock gen- erator (See Figure 24) ...
Page 51
... It is possible to use Timer baud rate generator and a clock generator simulta- neously. For this configuration, the baud rates and clock frequencies are not independent since both functions use the values in the RCAP2H and RCAP2L registers. Figure 24. Clock-out Mode C/ CLK PERIPH T2 T2EX AT89C5131 TR2 T2CON TH2 TL2 (8-bit) (8-bit) RCAP2H RCAP2L ...
Page 52
... AT89C5131 52 Table 47. T2CON Register T2CON - Timer 2 Control Register (C8h TF2 EXF2 RCLK Bit Bit Number Mnemonic Description Timer 2 overflow Flag 7 TF2 Must be cleared by software. Set by hardware on Timer 2 overflow, if RCLK = 0 and TCLK = 0. Timer 2 External Flag Set when a capture or a reload is caused by a negative transition on T2EX pin if EXEN2 = 1 ...
Page 53
... Timer 2 Output Enable bit 1 T2OE Cleared to program P1.0/T2 as clock input or I/O port. Set to program P1.0/T2 as clock output. Down Counter Enable bit 0 DCEN Cleared to disable Timer 2 as up/down counter. Set to enable Timer 2 as up/down counter. Reset Value = XXXX XX00b Not bit addressable AT89C5131 T2OE 0 DCEN 53 ...
Page 54
... Programmable Counter Array (PCA) AT89C5131 54 The PCA provides more timing capabilities with less CPU intervention than the standard timer/counters. Its advantages include reduced software overhead and improved accu- racy. The PCA consists of a dedicated timer/counter which serves as the time base for an array of five compare/capture modules ...
Page 55
... CPS0 CPS0 PCA Enable Counter Overflow Interrupt 0 ECF Cleared to disable CF bit in CCON to inhibit an interrupt. Set to enable CF bit in CCON to generate an interrupt. Reset Value = 00XX X000b Not bit addressable AT89C5131 To PCA modules overflow Bit Up/Down Counter CMOD ECF 0xD9 CCON 0xD8 CPS1 Selected PCA input ...
Page 56
... AT89C5131 56 The CMOD register includes three additional bits associated with the PCA (See Figure 25 and Table 49). • The CIDL bit allows the PCA to stop during idle mode. • The WDTE bit enables or disables the watchdog function on module 4. • The ECF bit when set causes an interrupt and the PCA overflow flag CF (in the CCON SFR set when the PCA timer overflows ...
Page 57
... PCA counter and the module's capture/compare register. • The next two bits CAPN (CCAPMn.4) and CAPP (CCAPMn.5) determine the edge that a capture input will be active on. The CAPN bit enables the negative edge, and AT89C5131 CCON 0xD8 To Interrupt priority decoder IE ...
Page 58
... AT89C5131 58 the CAPP bit enables the positive edge. If both bits are set both edges will be enabled and a capture will occur for either transition. • The last bit in the register ECOM (CCAPMn.6) when set enables the comparator function. Table 52 shows the CCAPMn settings for the various PCA functions. ...
Page 59
... CCAPnH and CCAPnL and these are the registers that store the 16-bit count when a capture occurs or a compare should occur. When a module is used in the PWM mode these registers are used to control the duty cycle of the output (see Table 53 and Table 54) AT89C5131 PWM ECCF MATn ...
Page 60
... AT89C5131 60 Table 53. CCAPnH Registers (n = 0-4) CCAP0H - PCA Module 0 Compare/Capture Control Register High (0FAh) CCAP1H - PCA Module 1 Compare/Capture Control Register High (0FBh) CCAP2H - PCA Module 2 Compare/Capture Control Register High (0FCh) CCAP3H - PCA Module 3 Compare/Capture Control Register High (0FDh) CCAP4H - PCA Module 4 Compare/Capture Control Register High (0FEh) ...
Page 61
... CCAPMn register. The PCA timer will be compared to the module’s capture registers and when a match occurs an interrupt will occur if the CCFn (CCON SFR) and the ECCFn (CCAPMn SFR) bits for the module are both set (see Figure 28). AT89C5131 4 3 ...
Page 62
... Figure 28. PCA Compare Mode and PCA Watchdog Timer Write to CCAPnL Reset Write to CCAPnH Enable 1 0 High Speed Output Mode AT89C5131 62 CCF4 CF CR CCAPnH CCAPnL Match 16-bit Comparator CH CL PCA Counter/Timer ECOMn CAPPn CAPNn MATn TOGn PWMn ECCFn CIDL WDTE Note: 1. Only for Module 4 Before enabling ECOM bit, CCAPnL and CCAPnH should be set with a non zero value, otherwise an unwanted match could happen ...
Page 63
... CCAPLn SFR the output will be low, when it is equal to or greater than the output will be high. When CL overflows from FF to 00, CCAPLn is reloaded with the value in CCAPHn. This allows updating the PWM without glitches. The PWM and ECOM bits in the module's CCAPMn register must be set to enable the PWM mode. AT89C5131 CCON 0xD8 PCA IT ...
Page 64
... PCA Watchdog Timer AT89C5131 64 Figure 30. PCA PWM Mode Overflow Enable ECOMn CAPPn CAPNn MATn TOGn PWMn ECCFn An on-board watchdog timer is available with the PCA to improve the reliability of the system without increasing chip count. Watchdog timers are useful for systems that are susceptible to noise, power glitches, or electrostatic discharge ...
Page 65
... Serial I/O Port Framing Error Detection 4136B–USB–09/03 The serial I/O port in the AT89C5131 is compatible with the serial I/O port in the 80C52. It provides both synchronous and asynchronous communication modes. It operates as an Universal Asynchronous Receiver and Transmitter (UART) in three full-duplex modes (modes 1, 2 and 3). Asynchronous transmission and reception can occur simul- taneously and at different baud rates ...
Page 66
... Automatic Address Recognition Given Address AT89C5131 66 Figure 33. UART Timings in Modes 2 and 3 RXD D0 D1 Start Bit RI SMOD0 = 0 RI SMOD0 = 1 FE SMOD0 = 1 The automatic address recognition feature is enabled when the multiprocessor commu- nication feature is enabled (SM2 bit in SCON register is set). Implemented in hardware, automatic address recognition enhances the multiprocessor communication feature by allowing the serial port to examine the address of each incoming command frame ...
Page 67
... XXXX XXXXb (all don’t care bits). This ensures that the serial port will reply to any address, and so, that it is backwards compatible with the 80C51 microcontrollers that do not support automatic address recognition. SADEN - Slave Address Mask Register (B9h Reset Value = 0000 0000b Not bit addressable AT89C5131 ...
Page 68
... Baud Rate Selection for UART for Mode 1 and 3 Baud Rate Selection Table for UART Internal Baud Rate Generator (BRG) AT89C5131 68 SADDR - Slave Address Register (A9h Reset Value = 0000 0000b Not bit addressable The Baud Rate Generator for transmit and receive clocks can be selected separately via the T2CON and BDRCON registers ...
Page 69
... Figure 35. Internal Baud Rate CLK PERIPH BRR 4136B–USB–09/03 auto reload counter 0 /6 BRG 1 BRL SPD • The baud rate for UART is token by formula: Baud_Rate = (BRL) = 256 - AT89C5131 /2 overflow 0 INT_BRG 1 SMOD1 SMOD1 CLK PERIPH (1-SPD [256 - (BRL)] SMOD1 CLK PERIPH ...
Page 70
... AT89C5131 70 Table 57. SCON Register – SCON Serial Control Register (98h FE/SM0 SM1 SM2 Bit Bit Number Mnemonic Description Framing Error bit (SMOD0 = 1) Clear to reset the error state, not cleared by a valid stop bit. FE Set by hardware when an invalid stop bit is detected. SMOD0 must be set to enable access to the FE bit ...
Page 71
... SADDR - Slave Address Register for UART (A9h – – – Reset Value = 0000 0000b SBUF - Serial Buffer Register for UART (99h – – – Reset Value = XXXX XXXXb AT89C5131 MHz OSCA Error (%) BRL 1.23 243 1.23 230 1.23 217 1.23 204 0.63 178 ...
Page 72
... AT89C5131 72 BRL - Baud Rate Reload Register for the internal baud rate generator, UART (9Ah – – – Reset Value = 0000 0000b Table 58. T2CON Register T2CON - Timer 2 Control Register (C8h TF2 EXF2 RCLK Bit Bit Number Mnemonic Description Timer 2 overflow Flag 7 TF2 Must be cleared by software ...
Page 73
... Cleared by hardware when interrupt or reset occurs. Set to enter idle mode. Reset Value = 00X1 0000b Not bit addressable Power-off flag reset value will be 1 only after a power on (cold reset). A warm reset doesn’t affect the value of this bit. AT89C5131 POF GF1 GF0 rises from 0 to its nominal voltage ...
Page 74
... AT89C5131 74 Table 60. BDRCON Register BDRCON - Baud Rate Control Register (9Bh Bit Bit Number Mnemonic Description Reserved 7 - The value read from this bit is indeterminate. Do not set this bit Reserved 6 - The value read from this bit is indeterminate. Do not set this bit Reserved 5 - The value read from this bit is indeterminate. Do not set this bit. ...
Page 75
... Individual Enable 4136B–USB–09/03 The AT89C5131 has a total of 15 interrupt vectors: two external interrupts (INT0 and INT1), three timer interrupts (timers 0, 1 and 2), the serial port interrupt, SPI interrupt, Keyboard interrupt, USB interrupt and the PCA global interrupt. These interrupts are shown in Figure 36 ...
Page 76
... Registers AT89C5131 76 Each of the interrupt sources can be individually enabled or disabled by setting or clear- ing a bit in the Interrupt Enable register (Table 62). This register also contains a global disable bit, which must be cleared to disable all interrupts at once. Each interrupt source can also be individually programmed to one out of four priority lev- els by setting or clearing a bit in the Interrupt Priority register (Table 63 ...
Page 77
... Timer 0 overflow interrupt Enable bit 1 ET0 Cleared to disable timer 0 overflow interrupt. Set to enable timer 0 overflow interrupt. External interrupt 0 Enable bit 0 EX0 Cleared to disable external interrupt 0. Set to enable external interrupt 0. Reset Value = 0000 0000b Bit addressable AT89C5131 ET1 EX1 ET0 1 0 EX0 77 ...
Page 78
... AT89C5131 78 Table 63. IPL0 Register IPL0 - Interrupt Priority Register (B8h PPCL PT2L Bit Bit Number Mnemonic Description Reserved 7 - The value read from this bit is indeterminate. Do not set this bit. PCA interrupt Priority bit 6 PPCL Refer to PPCH for priority level. Timer 2 overflow interrupt Priority bit ...
Page 79
... PT0H External interrupt 0 Priority High bit PX0H PX0L PX0H Reset Value = X000 0000b Not bit addressable AT89C5131 PSH PT1H PX1H PT0H Priority Level Lowest Highest Priority Level Lowest Highest Priority Level Lowest Highest Priority Level Lowest Highest Priority Level Lowest Highest ...
Page 80
... AT89C5131 80 Table 65. IEN1 Register IEN1 - Interrupt Enable Register (B1h EUSB - Bit Bit Number Mnemonic Description 7 - Reserved 6 EUSB USB Interrupt Enable bit 5 - Reserved 4 - Reserved 3 - Reserved SPI interrupt Enable bit 2 ESPI Cleared to disable SPI interrupt. Set to enable SPI interrupt Reserved Keyboard interrupt Enable bit ...
Page 81
... The value read from this bit is indeterminate. Do not set this bit. Reserved 1 - The value read from this bit is indeterminate. Do not set this bit. Keyboard Interrupt Priority bit 0 PKBL Refer to KBDH for priority level. Reset Value = XXXX X000b Bit addressable AT89C5131 PSPIL 0 PKBDL 81 ...
Page 82
... AT89C5131 82 Table 67. IPH1 Register IPH1 - Interrupt Priority High Register (B3h Bit Bit Number Mnemonic Description Reserved 7 - The value read from this bit is indeterminate. Do not set this bit. USB Interrupt Priority High bit 6 PUSBH The value read from this bit is indeterminate. Do not set this bit. ...
Page 83
... INT1 4 4 Timer UART 6 7 Timer Keyboard AT89C5131 Interrupt Request IE0 TF0 IE1 IF1 RI+TI TF2+EXF2 PCA CF + CCFn (n = 0-4) KBDIT SPI SPIIT USB UEPINT + USBINT Vector Address 0000h 0003h 000Bh 0013h 001Bh 0023h 002Bh 0033h 003Bh 0043h 004Bh 0053h 005Bh ...
Page 84
... Description Interrupt AT89C5131 84 The AT89C5131 implements a keyboard interface allowing the connection matrix keyboard based on 8 inputs with programmable interrupt capability on both high or low level. These inputs are available as an alternate function of P1 and allow to exit from idle and power down modes. ...
Page 85
... Keyboard interrupt request if the KBIE.1 bit in KBIE register is set. Must be cleared by software. Keyboard line 0 flag Set by hardware when the Port line 0 detects a programmed level. It generates a 0 KBF0 Keyboard interrupt request if the KBIE.0 bit in KBIE register is set. Must be cleared by software. Reset Value = 0000 0000b AT89C5131 KBF4 KBF3 KBF2 KBF1 1 ...
Page 86
... AT89C5131 86 Table 70. KBE Register KBE - Keyboard Input Enable Register (9Dh KBE7 KBE6 KBE5 Bit Bit Number Mnemonic Description Keyboard line 7 Enable bit 7 KBE7 Cleared to enable standard I/O pin. Set to enable KBF.7 bit in KBF register to generate an interrupt request. Keyboard line 6 Enable bit ...
Page 87
... Cleared to enable a low level detection on Port line 1. Set to enable a high level detection on Port line 1. Keyboard line 0 Level Selection bit 0 KBLS0 Cleared to enable a low level detection on Port line 0. Set to enable a high level detection on Port line 0. Reset Value = 0000 0000b AT89C5131 KBLS4 KBLS3 KBLS2 KBLS1 ...
Page 88
... Programmable LED AT89C5131 88 AT89C5131 have programmable LED current sources, configured by the regis- ter LEDCON. Table 72. LEDCON Register LEDCON (S:F1h) LED Control Register LED3 LED2 Bit Bit Number Mnemonic Description Port/LED3 Configuration 0 0 7:6 LED3 Port/LED2 Configuration 0 0 5:4 LED2 Port/LED1 Configuration ...
Page 89
... Each Slave peripheral is selected by one Slave Select pin (SS). This signal must stay low for any message for a Slave obvious that only one Master (SS high level) can drive the network. The Master may select each Slave device by software through port AT89C5131 Slave 1 Slave 3 ...
Page 90
... Baud Rate AT89C5131 90 pins (Figure 39). To prevent bus conflicts on the MISO line, only one slave should be selected at a time by the Master for a transmission Master configuration, the SS line can be used in conjunction with the MODF flag in the SPI Status register (SPSTA) to prevent multiple masters from driving MOSI and SCK (see Section “ ...
Page 91
... When the Master device transmits data to the Slave device via the MOSI line, the Slave device responds by sending data to the Master device via the MISO line. This implies full-duplex transmission with both data out and data in synchronized with the same clock (Figure 41). AT89C5131 Internal Bus SPDAT Shift Register ...
Page 92
... Master Mode Slave Mode Transmission Formats AT89C5131 92 Figure 41. Full-duplex Master/Slave Interconnection 8-bit Shift Register SPI Clock Generator Master MCU The SPI operates in Master mode when the Master bit, MSTR is set. Only one Master SPI device can initiate transmissions. Software begins the trans- mission from a Master SPI module by writing to the Serial Peripheral Data Register (SPDAT) ...
Page 93
... MOSI pin on the first SCK edge. Therefore the Slave uses the first SCK edge as a start transmission signal. The SS pin can remain low between transmis- sions (Figure 39). This format may be preferable in systems having only one Master and only one Slave driving the MISO data line. AT89C5131 ...
Page 94
... Mode Fault (MODF) Write Collision (WCOL) Overrun Condition Interrupts AT89C5131 94 The following flags in the SPSTA signal SPI error conditions: Mode Fault error in Master mode SPI indicates that the level on the Slave Select (SS) pin is inconsistent with the actual mode of the device. MODF is set to warn that there may have a multi-master conflict for system control ...
Page 95
... Set to have the SCK set to “1” in idle low. Clock Phase Cleared to have the data sampled when the SCK leaves the idle state (see 3 CPHA CPOL). Set to have the data sampled when the SCK returns to idle state (see CPOL). AT89C5131 SPI CPU Interrupt Request SPI Receiver/Error CPU Interrupt Request 4 3 ...
Page 96
... Serial Peripheral Status Register (SPSTA) AT89C5131 96 Bit Number Bit Mnemonic Description SPR2 SPR1 2 SPR1 SPR0 Reset Value = 0001 0100b Not bit addressable The Serial Peripheral Status Register contains flags to signal the following conditions: • Data transfer complete • Write collision • ...
Page 97
... However, special care should be taken when writing to them while a transmission is on-going: • Do not change SPR2, SPR1 and SPR0 • Do not change CPHA and CPOL • Do not change MSTR • Clearing SPEN would immediately disable the peripheral • Writing to the SPDAT will cause an overflow AT89C5131 ...
Page 98
... Two Wire Interface ( TWI Introduction AT89C5131 98 ) The Synchronous Serial Link Controller (SSLC) provides the selection of one synchro- nous serial interface among the two most popular ones: • Two Wire Interface (TWI). • Serial Peripheral Interface (SPI) When an interface is selected, the other is no longer available, its usage is exclusive. ...
Page 99
... Output Stage 4136B–USB–09/03 SSADR Address Register Comparator SSDAT Shift Register Arbitration and Sink Logic Timing and Control Logic Serial clock generator Timer 1 overflow SSCON Control Register Status Status Decoder Bits SSCS Status Register AT89C5131 8 ACK 8 F CLK PERIPH/ 4 Interrupt ...
Page 100
... SDA SCL S start condition AT89C5131 100 The CPU interfaces to the TWI logic via the following four 8-bit special function regis- ters: the Synchronous Serial Control register (SSCON; Table 84 and Table 79), the Synchronous Serial Data register (SSDAT; Table 85), the Synchronous Serial Control and Status register (SSCS ...
Page 101
... SSCS are possible. There are 40h, 48h or 38h for the master mode and also 68h, 78h or B0h if the slave mode was enabled (AA=logic 1). The appropriate action to be taken for each of these status code is detailed in Table . This scheme is repeated until a STOP condition is transmitted. AT89C5131 ...
Page 102
... Slave Receiver Mode Slave Transmitter Mode AT89C5131 102 SSIE, CR2, CR1 and CR0 are not affected by the serial transfer and are referred to Table . After a repeated START condition (state 10h) SSLC may switch to the master transmitter mode by loading SSDAT with SLA+W. In the slave receiver mode, a number of data bytes are received from a master transmit- ter (Figure 51) ...
Page 103
... SDA (serial data line). To avoid low level asserting on these lines when SSLC is enabled, the output latches of SDA and SLC must be set to logic 1. CR2 CR1 CR0 AT89C5131 Bit Frequency (kHz MHz MHz OSCA OSCA 47 62.5 53.5 71.5 62 100 12.5 16.5 100 - - - 0.5 < . < 62.5 0.67 < . < 83 (reload value range: F divided by OSCA 256 ...
Page 104
... Not acknowledge received after the slave address Not acknowledge received after a data byte Arbitration lost in slave address or data byte Arbitration lost and addressed as slave From master to slave From slave to master AT89C5131 104 Data 18h A P 20h Other master continues ...
Page 105
... Read data byte read data byte 0 0 Read data byte Read data byte Read data byte 1 1 AT89C5131 SI AA Next Action Taken by TWI Software SLA+W will be transmitted ACK will be transmitted SLA+W will be transmitted ACK will be transmitted SLA+W will be transmitted 0 X Logic will switched to master transmitter mode ...
Page 106
... Next transfer started with a repeated start condition Not acknowledge received after the slave address Arbitration lost in slave address or acknowledge bit Arbitration lost and addressed as slave From master to slave From slave to master AT89C5131 106 MR Data 50h 40h A P 48h Other master ...
Page 107
... Read data byte Read data byte AT89C5131 AA Next Action Taken by TWI Software 0 Data byte will be received and NOT ACK will be returned Data byte will be received and ACK will be returned 1 0 Data byte will be received and NOT ACK will be returned Data byte will be received and ACK will be returned ...
Page 108
... Status Code Status of the TWI Bus (SSCS) and TWI Hardware No SSDAT action A STOP condition or repeated START No SSDAT action A0h condition has been received while still No SSDAT action addressed as slave No SSDAT action AT89C5131 108 Application Software Response To SSCON To/from SSDAT STA STO ...
Page 109
... S SLA W A 60h A 68h General Call A 70h A 78h Any number of data bytes and their associated Data A acknowledge bits This number (contained in SSCS) corresponds defined state of the TWI bus AT89C5131 Data A Data A 80h 80h 88h Data A Data A 90h 90h ...
Page 110
... ACK has been received No SSDAT action or No SSDAT No SSDAT action or No SSDAT Last data byte in SSDAT action or has been transmitted C8h (AA=0); ACK has been No SSDAT received action or No SSDAT AT89C5131 110 Application Software Response To SSCON STA STO SI byte byte byte or ...
Page 111
... Status Code Status of the TWI bus (SSCS) and TWI hardware No relevant state F8h information available; SI= 0 Bus error due to an 00h illegal START or STOP condition AT89C5131 Data Data A A B8h C0h All 1’s A C8h Any number of data bytes and their associated ...
Page 112
... Registers AT89C5131 112 Table 84. SSCON Register SSCON - Synchronous Serial Control Register (93h CR2 SSIE STA Bit Bit Number Mnemonic Description Control Rate bit 2 7 CR2 See . Synchronous Serial Interface Enable bit 6 SSIE Clear to disable SSLC. Set to enable SSLC. Start flag 5 STA Set to send a START condition on the bus ...
Page 113
... A6 Slave address bit Slave address bit Slave address bit Slave address bit Slave address bit Slave address bit 1. General call bit 0 GC Clear to disable the general call address recognition. Set to enable the general call address recognition. AT89C5131 SC1 SC0 113 ...
Page 114
... Transport AT89C5131 114 The AT89C5131 implements a USB device controller supporting full speed data transfer in accordance with the USB 1.1 and 2.0 Specifications. In addition to the default control endpoint 0, it provides 6 other endpoints, which can be configured in control, bulk, inter- rupt or isochronous modes: • ...
Page 115
... DFU functions. The Run-Time configuration co- exists with the usual functions of the device, which may be USB Mass Storage for the AT89C5131 used to initiate DFU from the normal operating mode. The DFU config- uration is used to perform the firmware update after device re-configuration and USB reset ...
Page 116
... Serial Interface Engine (SIE) Figure 54. SIE Block Diagram End of Packet Detection Start of Packet Detection D+ D- Clk48 (48 MHz) AT89C5131 116 The SIE performs the following functions: • NRZI data encoding and decoding. • Bit stuffing and un-stuffing. • CRC generation and checking. • ...
Page 117
... C51 Endpoint FIFO write 4136B–USB–09/03 The Function Interface Unit provides the interface between the AT89C5131 and the SIE. It manages transactions at the packet level with minimal intervention from the device firmware, which reads and writes the endpoint FIFOs. Asynchronous Information ...
Page 118
... UEPSTA0 Endpoint 0 UBYCTH0 UEPSTA6 Endpoint 6 UBYCTH6 AT89C5131 118 • USB controller enable Before any USB transaction, the 48 MHz required by the USB controller must be correctly generated (See “Clock Controller” on page 19). The USB controller will be then enabled by setting the EUSB bit in the USBCON register. • ...
Page 119
... Summary of Endpoint Configuration: Do not forget to select the correct endpoint number in the UEPNUM register before accessing to endpoint specific registers. Table 88. Summary of Endpoint Configuration Endpoint Configuration Disabled Control Bulk-in Bulk-out Interrupt-In Interrupt-Out Isochronous-In Isochronous-Out AT89C5131 EPEN EPDIR EPTYPE 0b Xb XXb 1b Xb 00b 1b 1b 10b ...
Page 120
... UEPSTA0 Endpoint 0 UBYCTH0 UEPSTA6 Endpoint 6 UBYCTH6 AT89C5131 120 • Endpoint FIFO reset Before using an endpoint, its FIFO will be reset. This action resets the FIFO pointer to its original value, resets the byte counter of the endpoint (UBYCTLX and UBYCTHX registers), and resets the data toggle bit (DTGL bit in UEPCONX). ...
Page 121
... If the Host sends more bytes than supported by the endpoint FIFO, the overflow data won’t be stored, but the USB controller will consider that the packet is valid if the CRC is correct and the endpoint byte counter contains the number of bytes sent by the Host. AT89C5131 C51 UFI ...
Page 122
... Bulk/Interrupt OUT Transactions in Ping-pong Mode AT89C5131 122 Figure 60. Bulk/Interrupt OUT Transactions in Ping-pong Mode HOST OUT DATA0 (n Bytes) ACK DATA1 (m Bytes) OUT ACK OUT DATA0 (p Bytes) ACK An endpoint will be first enabled and configured before being able to receive Bulk or Interrupt packets. When a valid OUT packet is received on the endpoint bank 0, the RXOUTB0 bit is set by the USB controller ...
Page 123
... The firmware will clear the TXCMPL bit before filling the endpoint FIFO with new data. The firmware will never write more bytes than supported by the endpoint FIFO. All USB retry mechanisms are automatically managed by the USB controller. AT89C5131 C51 Endpoint FIFO Write Byte 1 Endpoint FIFO Write Byte 2 ...
Page 124
... Bulk/Interrupt IN Transactions in Ping-pong Mode AT89C5131 124 Figure 62. Bulk/Interrupt IN Transactions in Ping-pong Mode UFI HOST IN NACK IN DATA0 (n Bytes) ACK TXCMPL IN DATA1 (m Bytes) ACK TXCMPL IN DATA0 (p Bytes) ACK An endpoint will be first enabled and configured before being able to send Bulk or Inter- rupt packets. The firmware will fill the FIFO bank 0 with the data to be sent and set the TXRDY bit in the UEPSTAX register to allow the USB controller to send the data stored in FIFO at the next IN request concerning the endpoint ...
Page 125
... IN Zero Length Packet (see “Bulk/Interrupt IN Transactions in Standard Mode” on page 123). To send a STALL handshake, see “STALL Handshake” on page 128. • For a Control Read transaction, the status stage consists of a OUT Zero Length Packet (see “Bulk/Interrupt OUT Transactions in Standard Mode” on page 121). AT89C5131 125 ...
Page 126
... Transactions in Standard Mode Isochronous OUT Transactions in Ping-pong Mode AT89C5131 126 An endpoint will be first enabled and configured before being able to receive Isochro- nous packets. When a OUT packet is received on an endpoint, the RXOUTB0 bit is set by the USB controller. This triggers an interrupt if enabled. The firmware has to select the corre- sponding endpoint, store the number of data bytes by reading the UBYCTLX and UBYCTHX registers ...
Page 127
... The bank switch is performed by the USB controller each time the TXRDY bit is set by the firmware. Until the TXRDY bit has been set by the firmware for an endpoint bank, the USB controller won’t send anything at each IN requests concerning this bank. The firmware will never write more bytes than supported by the endpoint FIFO. AT89C5131 127 ...
Page 128
... STALL Handshake Start of Frame Detection Frame Number Data Toggle Bit AT89C5131 128 The EORINT bit in the USBINT register is set by hardware when a End Of Reset has been detected on the USB bus. This triggers a USB interrupt if enabled. The USB con- troller is still enabled, but all the USB registers are reset by hardware. The firmware will clear the EORINT bit to allow the next USB reset detection ...
Page 129
... The firmware has to clear the SPINT bit in the USBINT register before any other USB operation in order to wake up the USB controller from its Suspend mode. The USB controller is then re-activated. Figure 63. Example of a Suspend/Resume Management Detection of a SUSPEND State Detection of a RESUME State AT89C5131 USB Controller Init SPINT Clear SPINT Set SUSPCLK Disable PLL ...
Page 130
... Upstream Resume Figure 64. Example of REMOTE WAKEUP Management SET_FEATURE: DEVICE_REMOTE_WAKEUP Detection of a SUSPEND State Upstream RESUME Sent AT89C5131 130 A USB device can be allowed by the Host to send an upstream resume for Remote Wake Up purpose DEVICE_REMOTE_WAKEUP, the firmware will set to 1 the RMWUPE bit in the USB- CON register to enable this functionality ...
Page 131
... D+ USB Controller D- 4136B–USB–09/03 In order to be re-enumerated by the Host, the AT89C5131 has the possibility to simulate a DETACH - ATTACH of the USB bus. The V output voltage is between 3.0V and 3.6V. This output can be connected to the REF D+ pull-up as shown in Figure 65. This output can be put in high-impedance when the DETACH bit is set the USBCON register. Maintaining this output in high imped- ance for more than 3 µ ...
Page 132
... USB Interrupt Control System AT89C5131 132 Table 89. Priority Levels IPHUSB IPLUSB shown in Figure 68, many events can produce a USB interrupt: • TXCMPL: Transmitted In Data (see Table 96 on page 139). This bit is set by hardware when the Host accept a In packet. • RXOUTB0: Received Out Data Bank 0 (see Table 96 on page 139). This bit is set by hardware when an Out packet is accepted by the endpoint and stored in bank 0. • ...
Page 133
... Figure 68. USB Interrupt Control Block Diagram Endpoint 0..6) TXCMP UEPSTAX.0 RXOUTB0 UEPSTAX.1 RXOUTB1 UEPSTAX.6 RXSETUP UEPSTAX.2 STLCRC UEPSTAX.3 WUPCPU USBINT.5 EWUPCPU USBIEN.5 EORINT USBINT.4 EEORINT USBIEN.4 SOFINT USBINT.3 ESOFINT USBIEN.3 SPINT USBINT.0 ESPINT USBIEN.0 4136B–USB–09/03 EPXINT UEPINT.X EPXIE UEPIEN.X AT89C5131 EUSB IE1.6 133 ...
Page 134
... USB Registers AT89C5131 134 Table 90. USBCON Register USBCON (S:BCh) USB Global Control Register USBE SUSPCLK SDRMWUP Bit Number Bit Mnemonic Description USB Enable Set this bit to enable the USB controller. 7 USBE Clear this bit to disable and reset the USB controller, to disable the USB transceiver an to disable the USB controller clock inputs ...
Page 135
... This bit is set by hardware when a USB Suspend (Idle bus for three frame periods state for 3 ms) is detected. This triggers a USB interrupt when 0 SPINT ESPINT is set in see Figure 92 on page 136. This bit will be cleared by software BEFORE any other USB operation to re- activate the macro. Reset Value = 00h AT89C5131 EORINT SOFINT - 1 ...
Page 136
... AT89C5131 136 Table 92. USBIEN Register USBIEN (S:BEh) USB Global Interrupt Enable Register EWUPCPU Bit Number Bit Mnemonic Description Reserved 7-6 - The value read from these bits is always 0. Do not set these bits. Enable Wake Up CPU Interrupt Set this bit to enable Wake Up CPU Interrupt. (See “USBIEN Register ...
Page 137
... Low Register EPNUM set in UEPNUM Register UEPNUM (S:C7h) USB Endpoint Number), UBYCTHX Register UBYCTHX (S:E3h) USB Byte Count High Register EPNUM set in UEPNUM Register UEPNUM (S:C7h) USB Endpoint Number) or UEPCONX Register UEPCONX (S:D4h) USB Endpoint X Control Register. This value can Reset Value = 00h AT89C5131 ...
Page 138
... AT89C5131 138 Table 95. UEPCONX Register UEPCONX (S:D4h) USB Endpoint X Control Register EPEN - - Bit Bit Number Mnemonic Description Endpoint Enable Set this bit to enable the endpoint according to the device configuration. 7 EPEN Endpoint 0 will always be enabled after a hardware or USB bus reset and participate in the device configuration. ...
Page 139
... Control, Bulk and Interrupt endpoints. Then, the endpoint interrupt is triggered if enabled (see“UEPINT Register UEPINT (S:F8h read-only) USB Endpoint Interrupt Register” on page 143). This bit will be cleared by the device firmware before setting TXRDY. Reset Value = 00h 4136B–USB–09/ STALLRQ TXRDY STL/CRC AT89C5131 RXSETUP RXOUTB0 0 TXCMP 139 ...
Page 140
... AT89C5131 140 Table 97. UEPDATX Register UEPDATX (S:CFh) USB FIFO Data Endpoint EPNUM set in UEPNUM Register UEPNUM (S:C7h FDAT7 FDAT6 FDAT5 Bit Bit Number Mnemonic Description Endpoint X FIFO data FDAT [7:0] Data byte to be written to FIFO or data byte to be read from the FIFO, for the Endpoint X (see EPNUM) ...
Page 141
... Most Significant Byte of the byte count of a received data packet. The Least 2-0 BYCT[10:8] significant part is provided by UBYCTLX Register UBYCTLX (S:E2h) USB Byte Count Low Register EPNUM set in UEPNUM Register UEPNUM (S:C7h) USB Endpoint Number) (see Figure 98 on page 140). (S:C7h) USB Endpoint Number) Reset Value = 00h AT89C5131 ...
Page 142
... AT89C5131 142 Table 100. UEPRST Register UEPRST (S:D5h) USB Endpoint FIFO Reset Register EP6RST EP5RST Bit Bit Number Mnemonic Description Reserved 7 - The value read from this bit is always 0. Do not set this bit. Endpoint 6 FIFO Reset Set this bit and reset the endpoint FIFO prior to any other operation, upon ...
Page 143
... This bit is set by hardware when an interrupt is triggered by the (see Table 96 on page 139) and this endpoint interrupt is enabled by the UEPIEN Register 0 EP0INT UEPIEN (S:C2h) USB Endpoint Interrupt Enable Register (see Figure 102 on page 144). This bit is cleared by software. Reset Value = 00h AT89C5131 EP4INT EP3INT EP2INT EP1INT ...
Page 144
... AT89C5131 144 Table 102. UEPIEN Register UEPIEN (S:C2h) USB Endpoint Interrupt Enable Register EP6INTE EP5INTE Bit Bit Number Mnemonic Description Reserved 7 - The value read from this bit is always 0. Do not set this bit. Endpoint 6 Interrupt Enable 6 EP6INTE Set this bit to enable the interrupts for this endpoint. ...
Page 145
... FNUM6 FNUM5 Bit Bit Number Mnemonic Description Frame Number FNUM[7:0] are the lower 8 bits of the 11-bit Frame Number (See “UFNUMH FNUM[7:0] Register UFNUMH (S:BBh, read-only) USB Frame Number High Register” on page 145). Reset Value = 00h AT89C5131 CRCERR - FNUM10 FNUM4 FNUM3 ...
Page 146
... In this case, the higher priority interrupt service routine is executed. Once the interrupt is serviced, the next instruction to be executed after RETI will be the one following the instruction that put AT89C5131 into power-down mode. can be lowered to save further CC ...
Page 147
... Mode Memory ALE PSEN Idle Internal 1 Idle External 1 Power-down Internal 0 Power-down External 0 Note: 1. Port 0 can force a 0 level. A “one” will leave port floating. AT89C5131 Active Phase PORT0 PORT1 PORT2 Port Port 1 Port Data (1) Data Data Port 1 Floating Address Data Port ...
Page 148
... Registers AT89C5131 148 Table 106. PCON Register PCON (S:87h) Power Control Register SMOD1 SMOD0 - Bit Bit Number Mnemonic Description Serial Port Mode bit 1 7 SMOD1 Set to select double baud rate in mode Serial Port Mode bit 0 6 SMOD0 Set to select FE bit in SCON register. ...
Page 149
... Table 107. WDTRST Register WDTRST - Watchdog Reset Register (0A6h Reset Value = XXXX XXXXb Write only, this SFR is used to reset/enable the WDT by writing 01EH then 0E1H in sequence. AT89C5131 , where T CLK PERIPH 7 counter has been added to extend the Time-out = 12 MHz. To manage this feature, refer to OSCA ...
Page 150
... WDT just before entering power-down. In the Idle mode, the oscillator continues to run. To prevent the WDT from resetting the AT89C5131 while in Idle mode, the user should always set up a timer that will periodi- cally exit Idle, service the WDT, and re-enter Idle mode. ...
Page 151
... Pull ALE low while the device is in reset (RST high) and PSEN is high. • Hold ALE low as RST is deactivated. While the AT89C5131 is in ONCE mode, an emulator or test CPU can be used to drive the circuit Table 109 shows the status of the port pins during ONCE mode. Normal operation is restored when normal reset is applied. ...
Page 152
... Reduced EMI Mode AT89C5131 152 The ALE signal is used to demultiplex address and data buses on port 0 when used with external program or data memory. Nevertheless, during internal code execution, ALE signal is still generated. In order to reduce EMI, ALE signal can be disabled by setting AO bit. The AO bit is located in AUXR register at bit location 0. As soon set, ALE is no longer output but remains active during MOVX and MOVC instructions and external fetches ...
Page 153
... Freq (MHz CCOP I = 0.6 Freq (MHz CCIDLE AT89C5131 Stresses at or above those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. This is a stress rating only and functional operation of the device at these or any other condi- tions above those indicated in the operational sections of this specification is not implied ...
Page 154
... Maximum I per 8-bit port: OL Port Ports 1, 2 and Maximum total I for all output pins exceeds the test condition than the listed test conditions. AT89C5131 154 Min 2 0.15 PFDM . I would be slightly higher if a crystal oscillator used (see Figure RST = V (see Figure 71). ...
Page 155
... RST EA (NC) XTAL2 XTAL1 V SS Figure 73. Clock Signal Waveform for I V -0.5V CC 0.45V T CHCL Min 20%) OL AT89C5131 All other pins are disconnected All other pins are disconnected. Tests in Active and Idle Modes CC 0.7V CC 0.2V -0 CLCH 5ns. CLCH CHCL Typ Max Unit ...
Page 156
... USB DC Parameters AT89C5131 156 BUS GND 3 2 USB “B” Receptacle 1 pad Symbol Parameter V USB Reference Voltage REF V Input High Voltage for D+ and D- (Driven Input High Voltage for D+ and D- (Floating) IHZ V Input Low Voltage for D+ and Output High Voltage for D+ and D- ...
Page 157
... ALE to Valid Instruction In LLIV T ALE to PSEN LLPL T PSEN Pulse Width PLPH T PSEN to Valid Instruction In PLIV T Input Instruction Hold after PSEN PXIX T Input Instruction Float after PSEN PXIZ T Address to Valid Instruction In AVIV T PSEN Low to Address Float PLAZ AT89C5131 = 3.3V 10 MHz 3.3V 10%. CC 157 ...
Page 158
... AT89C5131 158 Table 113. AC Parameters for a Fix Clock ( MHz) Symbol T T LHLL T AVLL T LLAX T LLIV T LLPL T PLPH T PLIV T PXIX T PXIZ T AVIV T PLAZ Table 114. AC Parameters for a Variable Clock Symbol Type T Min LHLL T Min AVLL T Min LLAX T Max LLIV T Min LLPL T Min ...
Page 159
... ALE to Valid Data In LLDV T Address to Valid Data In AVDV T ALE LLWL T Address AVWL T Data Valid to WR Transition QVWX T Data set- High QVWH T Data Hold After WR WHQX T RD Low to Address Float RLAZ High to ALE high WHLH AT89C5131 T PXAV T PXIZ A0-A7 INSTR IN ADDRESS A8-A15 159 ...
Page 160
... AT89C5131 160 Table 116. AC Parameters for a Variable Clock ( MHz) Symbol T RLRH T WLWH T RLDV T RHDX T RHDZ T LLDV T AVDV T LLWL T AVWL T QVWX T QVWH T WHQX T RLAZ T WHLH Min Max 130 130 100 0 30 160 165 50 100 75 10 160 Units 4136B–USB–09/03 ...
Page 161
... RHDX T Max RHDZ T Max LLDV T Max AVDV T Min LLWL T Max LLWL T Min AVWL T Min QVWX T Min QVWH T Min WHQX T Max RLAZ T Min WHLH T Max WHLH T LLWL T QVWX T LLAX A0-A7 T AVWL ADDRESS A8-A15 OR SFR P2 AT89C5131 Standard Clock X2 Clock X Parameter ...
Page 162
... External Data Memory Read Cycle ALE PSEN RD PORT 0 ADDRESS PORT 2 OR SFR-P2 Serial Port Timing - Shift Register Mode AT89C5131 162 T LLDV T LLWL T AVDV T LLAX A0-A7 T RLAZ T AVWL ADDRESS A8-A15 OR SFR P2 Table 118. Symbol Description ( MHz) Symbol T XLXL T QVHX T XHQX T XHDX T XHDV Table 119 ...
Page 163
... AC inputs during testing are driven at V Timing measurement are made 0 0 For timing purposes as port pin is no longer floating when a 100 mV change from load voltage occurs and begins to float when a 100 mV change from the loaded V occurs mA AT89C5131 SET TI VALID VALID VALID VALID ...
Page 164
... This propagation delay is dependent on variables such as temperature and pin loading. Propa- gation also varies from output to output and component. Typically though (T delays are approximately 50 ns. The other signals are typically 85 ns. Propagation delays are incorporated in the AC specifications. AT89C5131 164 Valid in normal clock mode mode XTAL2 must be changed to XTAL2/2. STATE5 ...
Page 165
... Input PSEN Valid to RST Edge SVRL T Input PSEN Hold after RST Edge RLSX T Flash Internal Busy (Programming) Time BHBL Figure 74. Flash Memory - ISP Waveforms RST PSEN1 Figure 75. Flash Memory - Internal Busy Waveforms FBUSY bit AT89C5131 Conditions L Low V Valid X No Longer Valid Min Typ ...
Page 166
... USB AC Parameters V CRS Differential Data Lines AT89C5131 166 Rise Time 90% 90% 10 Table 124. USB AC Parameters Symbol Parameter t Rise Time R t Fall Time F t Full-speed Data Rate FDRATE V Crossover Voltage CRS Source Jitter Total to Next t DJ1 Transaction Source Jitter Total for Paired ...
Page 167
... Ordering Information Table 125. Possible Order Entries Part Number Memory Size (Kbytes) AT89C5131-RDTIL AT89C5131-PLTIL AT89C5131-S3SIL AT89C5131-TISIL Note: 1. Optional Packing and Package options (please consult Atmel sales representative): -Tape and Reel -Dry Pack -Known good dice 4136B–USB–09/03 Supply Voltage 32 3 ...
Page 168
... Packaging Information 64-lead VQFP AT89C5131 168 4136B–USB–09/03 ...
Page 169
... PLCC 48-lead MLF 4136B–USB–09/03 AT89C5131 169 ...
Page 170
... AT89C5131 170 4136B–USB–09/03 ...
Page 171
... SO 4136B–USB–09/03 AT89C5131 171 ...
Page 172
... Datasheet Change Log Changes from 4136A - 03/03 to 4136B - 09/03 AT89C5131 172 1. Added Two Wire Interface description. 2. AC/DC parameters modified. 4136B–USB–09/03 ...
Page 173
Table of Contents 4136B–USB–09/03 Features ................................................................................................. 1 Description ............................................................................................ 2 Block Diagram ....................................................................................... 3 Pinout Description ................................................................................ 4 Pinout.................................................................................................................... 4 Signals ...................................................................................................................7 SFR Mapping ....................................................................................... 12 Clock Controller .................................................................................. 19 Introduction ......................................................................................................... 19 Oscillator............................................................................................................. 19 PLL ..................................................................................................................... 20 Registers..............................................................................................................22 Dual ...
Page 174
Application-Programming-Interface .................................................................... 44 XROW Bytes....................................................................................................... 44 Hardware Conditions .......................................................................................... 44 Hardware Security Byte ...................................................................................... 45 On-chip Expanded RAM (ERAM) ....................................................... 46 Timer 2 ................................................................................................. 49 Auto-reload Mode ............................................................................................... 49 Programmable Clock Output .............................................................................. 50 Programmable Counter Array (PCA) ................................................ ...
Page 175
USB Controller .................................................................................. 114 Introduction ....................................................................................................... 114 Description........................................................................................................ 115 Configuration .................................................................................................... 118 Read/Write Data FIFO ...................................................................................... 120 Bulk/Interrupt Transactions............................................................................... 121 Control Transactions......................................................................................... 125 Isochronous Transactions..................................................................................126 Miscellaneous ....................................................................................................128 Suspend/Resume Management ........................................................................129 Detach Simulation..............................................................................................131 USB Interrupt System ....................................................................................... 131 USB Registers ...
Page 176
... No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems. ...