8051

C8051f312 microcontroller [closed]

柔情痞子 提交于 2019-12-02 13:04:26
I'm not very good at C language, but I have write a very simple code to a C8051F312 microcontroller. My code doesn't working. Please help me what did I wrong. #include C8051F310.h #include stdio.h sbit LED_16 = P1^7; // green LED: 1 = ON; 0 = OFF void init(void) { // XBRN registers_init XBR0 = 0x00; XBR1 = 0x00; // Enable the crossbar PCA0MD = 0X00; // port_init P0MDOUT = 0x00; // Output configuration for P0 P1MDOUT = 0x40; // Output configuration for P1 P2MDOUT = 0x00; // Output configuration for P2 P3MDOUT = 0x00; // Output configuration for P3 } void main(void) { init(); while (1) { LED_16

(8051) Check if a single bit is set

烂漫一生 提交于 2019-12-02 06:32:47
问题 I'm writing a program for a 8051 microcontroller. In the first part of the program I do some calculations and based on the result, I either light the LED or not (using CLR P1.7 , where P1.7 is the port the LED is attached to in the microcontroller). In the next part of the program I want to retrieve the bit, perhaps store it somewhere, and use it in a if-jump instruction like JB . How can I do that? Also, I've seen the instruction MOV C, P1.7 in a code sample. What's the C here? 回答1: The C

(8051) Check if a single bit is set

浪尽此生 提交于 2019-12-02 00:19:20
I'm writing a program for a 8051 microcontroller. In the first part of the program I do some calculations and based on the result, I either light the LED or not (using CLR P1.7 , where P1.7 is the port the LED is attached to in the microcontroller). In the next part of the program I want to retrieve the bit, perhaps store it somewhere, and use it in a if-jump instruction like JB . How can I do that? Also, I've seen the instruction MOV C, P1.7 in a code sample. What's the C here? The C here is the 8051's carry flag - called that because it can be used to hold the "carry" when doing addition