Some pins are not seen on the microcontroller, but can be found on the schematic diagram, indicating that these pins are not brought out
The pins on the microcontroller can be operated externally, and some unnecessary pins are directly connected inside the microcontroller.
Learning about microcontrollers is actually learning and operating registers. Read the instructions carefully.
The USB port of the MSP430 chip can create two com ports on the computer, one of which can be used for debugging
You can use the serial port debugging assistant to detect data, which is equivalent to integrating a serial port
After plugging in the USB, open the device manager, my computer win8 shortcut key win + x + m (win + x can bring up a menu, you will know it by yourself, which is equivalent to right-clicking the start menu in the lower left corner)
This is a virtual serial port. It is hard to find if you don't read the instructions carefully. I didn't find the p4.4 p4.5 serial port at first because they are integrated inside the microcontroller and not brought out for debugging.
V and Vcc on the chip are power supply terminals
G and Gnd are ground terminals, corresponding to the power supply terminal, forming a path. In simple terms, current flows in from Vcc and out from Gnd.
When programming a single-chip microcomputer, novices will inevitably be confused, such as the following code
These are the register operations for the serial port. UC is the abbreviation of USCI. USCI is below the below the below...
How do these things correspond to the hardware, and how are the operations on these variables converted into operations on the microcontroller hardware?
In fact, these things are defined in the header file. Each name corresponds to an address, which corresponds to the hardware.
It's just a name, which is why the domain name appears. If you don't know the domain name, it's the note of your QQ friends. I don't believe you haven't used the phone book...
Set: Enable Reset: Disable
IE Interrupt Enable Usually it is interrupt enable
SR State Register
RST is of course Reset
GIE General Interrupt Enable General interrupt enable
NMI Non Maskable Interrupt Non-maskable interrupt
POR Power On Reset Power-on Reset
PUC Power Up Clear Power on Clear
RXD Receive Exchange Data
TXD Transmit Exchange Data
CTL Control BTCTL Basic Timer Control Register
USCI Universal Communication Interface Universal Communication Interface, US should be a word
USART Universal Synchronous/Asynchronous Receive/Transmit Synchronous/Asynchronous serial communication, including SPI synchronous serial communication, Inter-IC (I square C), and there may be many serial communication methods. .
There is another word that looks similar: UART asynchronous serial communication, which is the asynchronous function in USART and cannot be synchronized. In general, UART is used in the same way as USART, because the synchronous mode is rarely used.
Timer A: TACTL Timer A Control Timer A Control Register TAR Timer A Register Timer A Count Register MC Model Control Model Control
Timer B: TBCTL Timer B Control Timer B Control Register TBR Timer B Register Timer B Count Register
MSP430's general IO ports P1--P6, each port is 8 bits, of which P1 and P2 have interrupt functions
The control registers are PNSEL PNDIR PNOUT PNIN
They are used to select the pin, control the direction of the pin (input or output), indicate the output value of the corresponding pin (for external reading), and indicate the input value of the corresponding pin (for external reading)
The interrupt function does not need to be called in the main function. It is automatically called when the corresponding interrupt occurs. When defining the interrupt function, it needs to be identified with a keyword. The following interrupt function
#pragma vector=TIMER1_A0_VECTOR //Indicates the interrupt vector, that is, the address, indicating which type of interrupt it is and to whom the interrupt belongs
TIMER1_A0_VECTOR is a predefined interrupt address of timer A0 in the microcontroller. The address before the = sign usually remains unchanged.
__interrupt void TIMER1_A0_ISR(void) //__interrupt is a keyword, indicating that this is an interrupt service function
{
t5ms_cnt++;
if (t5ms_cnt==2)
{
t10ms_flag=1;
t10ms_cnt++;
t5ms_cnt=0;
}
if (t10ms_cnt==10)
{
t100ms_flag=1;
t100ms_cnt++;
t10ms_cnt=0;
}
if (t100ms_cnt==10)
{
t1000ms_flag=1;
t100ms_cnt=0;
}
}
There are also many techniques for register operations in microcontrollers.
For example, this one
P1OUT |= BIT2
P1 has 8 bits in total. BIT2 is predefined as 0x02 in the header file, which is 00000010, and BIT3 is 00000100, all to simplify programming.
The above is equivalent to P1OUT = P1OUT | BIT2
Only the second bit of BIT2 is 1, and the rest are 0, so this formula will not affect the numbers in other positions. Any number | 0 will still be equal to itself.
Similarly, P4OUT ^= 0x80 P1OUT &= ~(BIT5+BIT6) You can almost understand it.
Note that | is different from || & is different from &&. Please search Baidu or Google for the principle yourself.
430 clock
Three clock sources:
LFXT1CLK low frequency clock source
XT2CLK high frequency clock source
DCOCLK Digitally Controlled RC Oscillator
Three clock systems for different modules
Note: Each device of 430 contains a low-speed crystal oscillator LFXT1
Finally, here are two pictures to commemorate
|