The use of the C51 flag of the MCU

Updated on technology 2024-05-08
10 answers
  1. Anonymous users2024-02-09

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

    The main function of this part of the program is to send an 8-bit number to serial, and each cycle sends everyone in the temp from high to low, using the carry flag to stage the highest bit.

  2. Anonymous users2024-02-08

    g = a >>1;The sign is shifted by 1 digit to the right, and the missing bit on the left is filled by the sign bit, and the positive number is 0,"00000000000000000000000000001101" = 13

    int f = b>> 1;The sign is shifted 1 bit to the right, and the missing bit on the left is filled by the sign bit, and the negative number is 1, "11111111111111111111111111111111" = -1

    So print it out at this time, g=13, gf=-1.

    g = a >>1;The unsigned is shifted to the right by 1 bit, and the missing bit on the left is filled with 0"00000000000000000000000000001101" = 13

    f = b>>>1;The unsigned is shifted 1 bit to the right, and the missing bit on the left is filled with 0, "01111111111111111111111111111111" = 2147483647

    So print it out at this time, g=13, gf=2147483647.

    f = b<< 1;The unsigned is shifted 1 bit to the left, and the missing bits on the right are filled with 0, "10000000000000000000000000000010" = -2

    So print it out at this time, f= -2 is c

  3. Anonymous users2024-02-07

    For example, if you use P0 and P2 to expand the external RAM (that is, use P0 and P2 to connect with the corresponding pins of 62256), assuming that you connect to WR, RD, and CS, then you can determine an address of the external RAM, and when you want to write a byte to an address of the external RAM, the address can be set to xbyte

    0x4000], where wr, cs is low, and rd is high, that is, 4 (0100) of the high position

    That is, and the output of the low level, and the output of the high level, of course, the purpose is to strobe 62256 and write data to 62256), other bits can be determined according to the situation (that is, what other bits are not important, the key is to control wr, cs, rd bits to meet the strobe, read, write regulations), now we write a 26 to 62256 into you can use this statement: xbyte

    0x4000]

    Because I don't know the connection situation of your C51 pins, I can only give the most common example (forgive me!). Generally speaking, xbyte is used for external extensions.

  4. Anonymous users2024-02-06

    void wr_595(void)

    uchar x;

    for (x=0;x<8;x++)

    temp=temp<<1;Does the shift left statement have a carry function? Right shift with carry function?

    sdata_595=cy;Is this cy the carry flag for the assembly? It's not mentioned in the book!

    sclk_595=1;

    nop_()

    nop_()

    sclk_595=0;

    1;Does the shift left statement have a carry function? Right shift with carry function?

    Answer: The meaning of this sentence is to shift temp one place to the left. C51 cannot implement the displacement with carry-on bits, it can only be embedded in the assembly in C, or in a special way:

    cy=acc&1;or cy=acc&0x80 (different registers can be used depending on the situation);This will allow the removed bits to be sent to the sign bits.

    For example: unsigned char c;

    acc=c;

    cy=acc&1;When these two statements are compiled, they will produce the right-shift and left-shift instructions with the carry-in bits.

    2 sdata_595=cy;Is this cy the carry flag for the assembly? It's not mentioned in the book!

    A: Yes. According to the textbook, C51 discards the data that was removed, so I doubt the correctness of this program.

    It stands to reason that this is a serial output program, and the number in the temp is sent to CY in turn, and it is sent out during the high level of the SCLK 595, which is an IIC serial communication. But the removed data will not go into the cy, but will be discarded, see how the program is written in the front.

  5. Anonymous users2024-02-05

    The bus is equivalent to the highway, the register is the houseside of the road, and the inside of the CPU is equivalent to a busy area on the side of the road

    Bit operations are operations within or between registers, which is equivalent to the movement of people between houses in a busy area

    Bus operation generally refers to the operation between the CPU and the peripherals, that is, the operation from the highway to or out of the busy area

    I don't know

  6. Anonymous users2024-02-04

    There are two ways to say the address of your home, such as what province, what city, what district, what road, and how many numbers! This is a bit operation. One more, east longitude xNorth latitude y, this should be the terminus. This is what I understand as bit operation and bus operation.

  7. Anonymous users2024-02-03

    I can't find the include file, I can't use scanf and printf in 51 microcontrollers!

  8. Anonymous users2024-02-02

    1. This sentence is right, if it is a jump, then there will be sp stack chaos, and there is an operation to protect the scene when entering the interrupt, that is, the address pressure stack, after you finish executing, there will be no out-of-stack operation when you jump back, or how many times will make the sp full. What's more, do you know when it went into hiatus?

    2. It should be th0=1eh, tl0=0ch, and the answer is wrong.

    3. PC can be used, but it can't be assigned, of course, it does not have a physical address, generally speaking, the value size is automatically changed by hardware during the program execution. Here's how to use it:

    movc a,@a+pc

    4. MOV 20h, @dptr does not have this instruction, DPTR can only be accessed through MOVC or MOVX, and can only be transmitted to accumulator A.

    5. Yes, only the breakpoint address can be protected, not the site such as PSW status, etc.

    6. Yes, whether there is a sign or not depends on your own decision, generally speaking, the highest bit is a negative number, and the bit 0 is a positive number, which is a signed number, without special instructions and settings, it is generally an unsigned number.

    7. I feel that your 0100h should be the address of the current transfer instruction, that is, the address of sjmp.

  9. Anonymous users2024-02-01

    1. Xu Hanbin's version of the microcomputer principle textbook P144 says that "the last instruction of the interrupt service program must be the interrupt return instruction reti", is this sentence wrong?

    If the last sentence is a jump instruction, isn't it, but the program will not return to the breakpoint, and the PC will also fill in the PC address at the jump point.

    Write jump commands, or whatever else you want. MCUs will execute.

    However, if the microcontroller does not execute the RETI instruction, the interrupt program will not end.

    If you don't write reti, the microcontroller will be in the interrupt program forever.

    2. If the initial value of the mode 0 timer t0 is 1e0ch, then the initial values of th0 and tl0 are () respectively

    The answer to this question is f0h, 0ch, I think it's clearly 1eh, 0ch, is the answer wrong?

    Written as binary: 1e0ch = 0001 1110 0000 1100b

    Take it 13 bits lower and write it as the top eight digits and the bottom five digits

    The initial value of method 0 should be: f c.

    3. "MCS 51's program counter PC cannot be used by the user because he has no address", first of all, what does it mean to be used by the user? Secondly, it doesn't have an address, so where the hell is he?

    The value of the PC, all the time, is automatically added to one, and this feature is not controllable by the user.

    However, users can use JMP commands to change the value of the PC.

    Saying that the PC can't be used by the user is actually that he won't use it.

    51 There is indeed no PC address in the MCU, because no one needs this address.

    4. mov 20h,@dptr This statement is wrong because DPTR can only be used for off-chip addressing.

    This directive does not exist.

    Can DPTR only be used for off-chip addressing?

    Take a look at the instruction list and you'll find out.

    5. "80C51 single-chip microcomputer subroutine can automatically protect the breakpoint and the site when it is called", this sentence is wrong, is it because it can only automatically protect the breakpoint and cannot automatically protect the site?

    When interrupted, the 51 single-chip microcomputer adopts the method of pressing the stack to automatically protect the breakpoint address.

    Protecting the site ?

    MCU, don't know what your site is.

    Linking the microcontroller with the protection site is that the dog wears a chew, Hule!

    6. mov a, 33h is an unsigned number, right? So what if I want to move in a signed number.

    Just write a minus sign.

    mov a, #-33h

    That's it. 7. Why is the offset of forward transfer equal to (destination address + 0100h) - (original address + 3), and what is 0100h?

    Writing programs is now done with compiler software.

    Compile the software and automatically calculate the offsets in the program.

    Programmers, there is no need to discuss the calculation of offsets, and the derivation of formulas.

    Some textbooks, the author's thinking, is still in the stage of manual compilation, clinging to the incomplete, ignore him.

    0100h, is 256.

  10. Anonymous users2024-01-31

    The book says that the normal and perfect interrupt procedure needs to be terminated by reti at the end. You can end it in other ways, and of course the program can continue. But I don't recommend that you use it that way.

    First of all, the interrupt program will protect the site before responding, and store some data into the stack, if there is no reti instruction, the stack data will not be released, and the stack will be crowded and overflowed after multiple interruptions, and unpredictable execution results will occur. Some people don't know why their programs run away inexplicably, often because they don't pay attention to these details, and personalized programs need to be used skillfully to avoid catastrophic failures.

    th0=1eh, tl0=0ch, but if his initial value means the set timed time, th0=e1h, tl0=f4h

    The PC cannot read or change its value directly.

    When using pointers, there is another parameter that cannot be directly addressed.

    The interrupt program will be automatically protected, the subroutine will not be automatically protected, and if necessary, you must arrange the instructions in the subprogram yourself.

    51 MCUs only have unsigned numbers, if you want to treat them as signed numbers, you need to convert and identify the values in the program. Of course, if you're writing a program in C, the compiler (like Keilc) will automatically handle your various data types.

    There is only an adder in the microcontroller, and the subtraction is also done with the adder, the subtracted number - the subtracted number = the subtracted number + the complement of the subtracted number. 100h is a method for data conversion when finding the complement of negative numbers.

Related questions
16 answers2024-05-08

Scheduled interrupts, external interrupts?

12 answers2024-05-08

If the timer count value is not enough, you can first set the sum number of 1, such as 1ms, and then add another number to 10 to 100ms to get the 1s time.

10 answers2024-05-08

Asynchronous serial communication means that both parties use a character (including specific additional bits) as the unit of data transmission, and the sender does not necessarily transmit the characters at intervals. Synchronous serial communication is the one that allows a sequence of characters to be sent consecutively, each with the same number of data bits and no start and stop bits. Asynchronous serial communication means that the time interval between two bytes in the communication is not fixed, while the time interval between two adjacent bits in the same byte is fixed. >>>More

5 answers2024-05-08

What kind of single-chip microcomputer do you use?,Now the general single-chip microcomputer has an internal hardware watchdog.,Even 8051 has it (like),But it seems to be a fixed time.,But it can also be used.,Not to mention other high-performance。 If there really isn't, there's a whole bunch of software watchdog C programs on the web. >>>More

5 answers2024-05-08

8086 belongs to the micro process unit (MPU) and is a microprocessor. >>>More