Re-pick the MCU third day interrupt explanation (a)

Source: Internet
Author: User

52 Single-Chip microcomputer:

Interrupt Source:

into0--External interrupt 0, introduced by the P3.2 Port line, is caused by a low level or a falling edge. into1--external interrupt 1, with P3.3 Port line introduced, low level or falling edge caused. t0--Timer/Counter 0 interrupt, caused by T0 counter full back 0. t1--Timer/Counter 1 interrupt, caused by T1 counter full back 0. t2--Timer/Counter 2 interrupt, caused by T2 counter full back 0. ti/ri--serial port interrupts, serial ports complete a frame character send/receive after the cause.MCU when using interrupt function, usually need to set up two interrupt-related registers:① interrupt allow register IE② Interrupt priority Register IPOne, interrupt allow register IE

Function:

ea--Global interrupt allow bitea=1 turn on global interrupt controlea=0 shutdown all interrupts
ET2 Timer/Counter 2 interrupt allow bitet2=1 Open T2 Interruptet2=0 shutdown T2 InterruptES serial interrupt allow bit ET1 Timer 1 interrupt allow bit EX1 external interrupt 1 allow bit
ET0 Timer/Counter 0 interrupt allow bit EX0 external interrupt allow bit two, interrupt priority register IP
PSSerial priority Control bitPs=1Serial port interrupt defined as high-priority interruptps=0Serial port interrupt defined as low priority interrupt PT1 Timer/Counter 1 priority control bit PX1 external Interrupt 1 interrupt priority control bit PT0 Timer/Counter 0 priority control bit PX0 external Interrupt 0 interrupt priority control bit note: The timer system is a separate hardware part of the MCU, It is connected and interacting with the CPU and crystal through some control lines inside, and once the CPU is set to start the Timer function, the timer will automatically start timing under the action of Crystal oscillator, and when the timer count is full, it will interrupt, that is, notify the CPU of such processing.MCU when using the Timer/counter function, usually need to set up two timer-related registers:① Working mode register Tmod② Control Counter TconOne, working mode Register TMOD Gate Gate Control gate=0 Timer/counter start and stop only by Tcon in the Register TRX (x=0,1) to control gate=1 Timer/counter start and Stop by TRX (Tcon) in the x=0,1 register And the level state on the external interrupt pin (INT0 or INT1) to jointly control the C/T Timer mode and the counter mode select bit (1 for Counter mode, 0 for timer mode) M1M0 working mode select bit each timer has 4 working mode, they are set by M1M0 two, Timer/ Counter Control Register Tcon

IF1 Timer 1 Overflow flag bit TR1 timer 1 run control bit by software clear 0 off timer 1, when gate=1, and INT1 for high power, TR1 1 start timer 1; gate=0 1 start Timer TR1 external interrupt 1 request flag when 1IE1 1 o'clock is the level trigger mode, each machine cycle s5p2 sampling INT1 pin, if the INT1 foot is low level. Then set 1, otherwise IE1 0. When it1=0, the INT1 is triggered by the jump edge, when the first machine cycle is sampled to INT1 for low, then IE1 1, is the external interrupt 1 is the CPU request interrupt, when the CPU response is interrupted, turn to interrupt service program, the bit is hardware clear 0. IT1 external Interrupt 1 trigger mode Select bit It1=0 is the level trigger, the pin INT1 on the low active it1=1 is the jump edge trigger mode, pin INT1 on the falling edge of the effective IE0 ibid.calculating the initial value problem of timers52 MCU Internal 12 times times the frequency division, assuming that the use of 12MHZ crystal oscillator, then 12 clock cycle for a machine cycle, then the machine cycle is 1us. Take timer 1, working mode 1 as an example. A 16-bit counter overflow is required to count 2^16-1 number = 65536. Approx. 65.5ms if you want to schedule 50ms, (65536-50000)/256 reprint to THX (65536-50000)/256 reprint to TLX formula: thx= (65536-50000)/256ltx = (65536-50000)/ 256How Interrupt service functions are written:void function name () interrupt interrupt number using Workgroup {Interrupt Service program contents}the initialization process of the timer is as follows① assign values to Tmod to determine how T0 and T1 work ② calculate the initial value and write the initial value to Th0,tl0, or Th1,tl1③ interrupt mode, then assign value to IE, open interrupt ④ make TR0 or TR1 set, start Timer/counter timer or Count icon:

Re-pick the MCU third day interrupt explanation (a)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.