51 MCU problem, please give the necessary note 20

Updated on technology 2024-05-26
14 answers
  1. Anonymous users2024-02-11

    void t0(void) interrupt 1 using 0 uses timer 0, using0 indicates that the first memory is used.

    th0=(65536-500)/256;Timer 0, fixed height, 8 digits, initial value, 5ms

    tl0=(65536-500)%256;The timer is 0 and low, and the initial value of 8 bits is set at 5ms

    When it's wrong*

    If the wrong light is on, the light of the car is not lit.

    bb++;if(bb==800) 5*800=4s, that is, after 4 seconds of Heng Lu Xiao, bb=0;

    alarmflag=~alarmflag;Alarm negation.

    if(alarmflag==1) if the alarm is raised.

    p0_0=~p0_0;Let the small light at the mouth turn on or off, it depends on the program in front of you.

    aa++;if(aa==800) 5*800=4s, after 4 seconds.

    aa=0;p0_1=~p0_1;Let the small light at the mouth turn on or off, it depends on the program in front of you.

    second3++;

    if(second3==6400) After 32 seconds, it is reset.

    second3=0;

    hibitflag=0;

    errorflag=0;

    rightflag=0;

    cmpflag=0;

    p0_1=1;

    alarmflag=0;

    bb=0;aa=0;

    When it's right*

    If correct. p0_1=0;The light is on.

    cc++;if(cc<1000) How long does it take to have a response, it depends on your previous program.

    okflag=1;

    else if(cc<2000) if that reaction does not appear; There will be another reaction, also depending on the program in front of you.

    okflag=0;

    else These are all depending on the program you have above, you don't hang out, I guess the function you want to implement is,,The lights don't come on

    errorflag=0;

    rightflag=0;

    hibitflag=0;

    cmpflag=0;

    p0_1=1;

    cc=0;oka=0;

    okb=0;

    okflag=0;

    p0_0=1;

    if(okflag==1)

    oka++;

    if(oka==2)

    oka=0;

    p0_0=~p0_0;

    elseokb++;

    if(okb==3)

    okb=0;

    p0_0=~p0_0;

  2. Anonymous users2024-02-10

    org 0000h ;Set the starting address of the program mov a, 20h ; the number 20h, sent to AMOV 21h, A; The contents of a are sent to 21h, and the 21h unit is also 20h

    mov 22h,a ;The content in a is sent to 22h, and the 22h unit is also 20h

    mov 31h,a ;The contents of a are sent to 31h, and the 31h unit is also 20h

    aa:sjmp aa ;In-situ transfer, stop, crash end; Come to an end.

    Question added: MOV A, 77h

    MOV 40h, 255 is sufficient.

  3. Anonymous users2024-02-09

    org 0000h

    mov a,#20h;Assign immediate numbers to ACC

    mov 21h,a;assign the value of a to the data storage unit 21hmov 22h,a; assign the value of a to the data storage unit 22hmov 31h,a; Assign the value of a to the data storage unit 31HAA: sjmp aa; The program is suspended.

    Supplementary. mov a,#77h

    mov 40h,0ffhend

  4. Anonymous users2024-02-08

    If each sentence is properly annotated, I don't think LZ will be able to understand it very well (not sarcastically, I am).

    Let's talk about the whole process roughly.,Personally, I feel that this program should be a marquee or something.。

    First, the output 0x0f on the P1 port, then move the 0x0f to the left 7 times in turn and output on the P1 port each time, after 7 times to move the output to the left, the output of the P1 port after moving the left 7 times, and move the output to the right for 6 consecutive times, and so ,,,on.

  5. Anonymous users2024-02-07

    It's so simple to translate, so why bother.

  6. Anonymous users2024-02-06

    Before reading, the SDA should be set to 1, that is, SDA=1, otherwise if it is 0, it will be low, and when the external data is read, even if it is high, it will be pulled down to 0

  7. Anonymous users2024-02-05

    scl=0 should pull the clock down so that it has a rising edge to latch the data, and sda=1 is to write 1 before reading the data.

  8. Anonymous users2024-02-04

    If you refer to the content of Philips' I2C bus protocol, these are easy to understand.

  9. Anonymous users2024-02-03

    It's a low-level to high-level jump.

  10. Anonymous users2024-02-02

    Clk Dina Dinb Clear is defined by yourself, and you can only know what function it stands for by looking at the schematic.

    All four sentences mean the same thing, and clk dina dinb clear stands for pins.

    After supplementing, look downstairs, haha.

    ..Upstairs.

  11. Anonymous users2024-02-01

    These four sentences are macro assembly statements, which connect the four pins of 74ls164 to it, and replace them with clk dina dinb clear when using these four pins in the program in the future

  12. Anonymous users2024-01-31

    You will definitely be able to understand every statement of this program, there is no need to add comments to you, tell you the principle of PWM, and you will understand it by comparing it with the program.

    You want to use 51 to generate PWM to control LED, first you need to determine the period T and duty cycle D of PWM, after determining these, you can use the timer to generate a time reference T, for example, the time when the timer overflows n times is the time of the high level of PWM, then D*T = N*T, and similarly you can find out how many time benchmarks N are needed for PWM low level time'

    Then you can write a program to initialize the value of a given timer according to your time benchmark t, and then turn on the timer, define a flag bit, and decide whether the output is high or low according to the state of the flag, assuming that the output is high when flag=1 is defined, use a variable to record the number of timer interruptions, and let the variable that records the number of interruptions +1 each interrupt, and judge whether the value of this variable has reached n in the interrupt program, if it reaches the high level of time, Then change the flag to 0, output low, and record the value of the interrupt variable to zero, still +1 each time it interrupts, and jump to determine whether the value of the recorded variable reaches n according to the situation of flag=0'If it arrives, it means that the low level of the PWM is enough, then change flag=1, change the output to the high level, and record the number of times variable to zero, start again, and so on to get the PWM waveform you want.

  13. Anonymous users2024-01-30

    I don't know what kind of comment you want, it's a timer 0, a timing interrupt program that works in mode 1, the timing time of the timer seems to be 500 machine cycles, and the rest is some if conditional statements and flag flag judgments, and the p0 port is reversed or something.

  14. Anonymous users2024-01-29

    void t0(void) interrupt 1 using 0 timer 0 interrupt ingress.

    if(alarmflag==1)

    aa++;if(aa==800)

    second3++;

    if(second3==6400)

    Another way to deal with it.

    else if(cc<2000)

    elseif(okflag==1)

    Else I don't know what your flag means, it's hard to annotate, it is recommended later, don't aa, bb what, alarmflag is not very intuitive?

Related questions
9 answers2024-05-26

This is normal, because the light on and off is driven by the low level of the single-chip microcomputer (as you can see from your program), and the high-low level load capacity given by the single-chip microcomputer is not very strong, that is to say, although it reaches the voltage, but the current is relatively small, and we write the same situation when we write programs. No problem, don't worry.

16 answers2024-05-26

Scheduled interrupts, external interrupts?

10 answers2024-05-26

< symbol indicates a left shift, and the highest digit enters the carry symbol C, which is the CY used below >>>More

11 answers2024-05-26

p is bigger, your { } is not paired, more or less one.

6 answers2024-05-26

In this case, it depends on sp, ret is equal to (sp) pch, sp-1 sp (sp) pcl, sp-1 sp >>>More