头像-295659

STM32ZET6

  • 单片机、嵌入式、EDA/PCB、传感器/MEMS
  • 消费电子

个人成就

获得 411 次赞

帮助过290人

这个圆形的PCB是怎么画出来的?

在边框下面来设置,画圆就行,然后边框就是圆形了

请教单片机外部中断问题,小白求助

中断里面死循环就跳不出来了,除非有高的优先级中断打断他,判断长短按可以加个延时再判断按键的电平,如果恢复了就是短按

请问单片机串口的初始化都有哪些必需的步骤呢?

没问题。串口范例程序,可以参考下#include "reg51.h"#include "intrins.h"typedef unsigned char BYTE;typedef unsigned int WORD;#define FOSC 11059200L      //System frequency#define BAUD 9600           //UART baudrate/@@*Define UART parity mode*/#define NONE_PARITY     0   //None parity#define ODD_PARITY      1   //Odd parity#define EVEN_PARITY     2   //Even parity#define MARK_PARITY     3   //Mark parity#define SPACE_PARITY    4   //Space parity#define PARITYBIT NONE_PARITY   //Testing even paritysbit bit9 = P2^2;           //P2.2 show UART data bit9bit busy;void SendData(BYTE dat);void SendString(char *s);void main(){#if (PARITYBIT == NONE_PARITY)    SCON = 0x50;            //8-bit variable UART#elif (PARITYBIT == ODD_PARITY) || (PARITYBIT == EVEN_PARITY) || (PARITYBIT == MARK_PARITY)    SCON = 0xda;            //9-bit variable UART parity bit initial to 1#elif (PARITYBIT == SPACE_PARITY)    SCON = 0xd2;            //9-bit variable UART parity bit initial to 0#endif    TMOD = 0x20;            //Set Timer1 as 8-bit auto reload mode    TH1 = TL1 = -(FOSC/12/32/BAUD); //Set auto-reload vaule    TR1 = 1;                //Timer1 start run    ES = 1;                 //Enable UART interrupt    EA = 1;                 //Open master interrupt switch    SendString("STC12C5A60S2\r\nUart Test !\r\n");    while(1);}/@@*----------------------------UART interrupt service routine----------------------------*/void Uart_Isr() interrupt 4{    if (RI)    {        RI = 0;             //Clear receive interrupt flag        P0 = SBUF;          //P0 show UART data        bit9 = RB8;         //P2.2 show parity bit    }    if (TI)    {        TI = 0;             //Clear transmit interrupt flag        busy = 0;           //Clear transmit busy flag    }}/@@*----------------------------Send a byte data to UARTInput: dat (data to be sent)Output:None----------------------------*/void SendData(BYTE dat){    while (busy);           //Wait for the completion of the previous data is sent    ACC = dat;              //Calculate the even parity bit P (PSW.0)    if (P)                  //Set the parity bit according to P    {#if (PARITYBIT == ODD_PARITY)        TB8 = 0;            //Set parity bit to 0#elif (PARITYBIT == EVEN_PARITY)        TB8 = 1;            //Set parity bit to 1#endif    }    else    {#if (PARITYBIT == ODD_PARITY)        TB8 = 1;            //Set parity bit to 1#elif (PARITYBIT == EVEN_PARITY)        TB8 = 0;            //Set parity bit to 0#endif    }    busy = 1;    SBUF = ACC;             //Send data to UART buffer}/@@*----------------------------Send a string to UARTInput: s (address of string)Output:None----------------------------*/void SendString(char *s){    while (*s)              //Check the end of the string    {        SendData(*s++);     //Send current char and increment string ptr    }}

请问单片机串口的初始化都有哪些必需的步骤呢?

串口的范例,可以参考下#include "reg51.h"#include "intrins.h"typedef unsigned char BYTE;typedef unsigned int WORD;#define FOSC 11059200L      //System frequency#define BAUD 9600           //UART baudrate/@@*Define UART parity mode*/#define NONE_PARITY     0   //None parity#define ODD_PARITY      1   //Odd parity#define EVEN_PARITY     2   //Even parity#define MARK_PARITY     3   //Mark parity#define SPACE_PARITY    4   //Space parity#define PARITYBIT NONE_PARITY   //Testing even paritysbit bit9 = P2^2;           //P2.2 show UART data bit9bit busy;void SendData(BYTE dat);void SendString(char *s);void main(){#if (PARITYBIT == NONE_PARITY)    SCON = 0x50;            //8-bit variable UART#elif (PARITYBIT == ODD_PARITY) || (PARITYBIT == EVEN_PARITY) || (PARITYBIT == MARK_PARITY)    SCON = 0xda;            //9-bit variable UART parity bit initial to 1#elif (PARITYBIT == SPACE_PARITY)    SCON = 0xd2;            //9-bit variable UART parity bit initial to 0#endif    TMOD = 0x20;            //Set Timer1 as 8-bit auto reload mode    TH1 = TL1 = -(FOSC/12/32/BAUD); //Set auto-reload vaule    TR1 = 1;                //Timer1 start run    ES = 1;                 //Enable UART interrupt    EA = 1;                 //Open master interrupt switch    SendString("STC12C5A60S2\r\nUart Test !\r\n");    while(1);}/@@*----------------------------UART interrupt service routine----------------------------*/void Uart_Isr() interrupt 4{    if (RI)    {        RI = 0;             //Clear receive interrupt flag        P0 = SBUF;          //P0 show UART data        bit9 = RB8;         //P2.2 show parity bit    }    if (TI)    {        TI = 0;             //Clear transmit interrupt flag        busy = 0;           //Clear transmit busy flag    }}/@@*----------------------------Send a byte data to UARTInput: dat (data to be sent)Output:None----------------------------*/void SendData(BYTE dat){    while (busy);           //Wait for the completion of the previous data is sent    ACC = dat;              //Calculate the even parity bit P (PSW.0)    if (P)                  //Set the parity bit according to P    {#if (PARITYBIT == ODD_PARITY)        TB8 = 0;            //Set parity bit to 0#elif (PARITYBIT == EVEN_PARITY)        TB8 = 1;            //Set parity bit to 1#endif    }    else    {#if (PARITYBIT == ODD_PARITY)        TB8 = 1;            //Set parity bit to 1#elif (PARITYBIT == EVEN_PARITY)        TB8 = 0;            //Set parity bit to 0#endif    }    busy = 1;    SBUF = ACC;             //Send data to UART buffer}/@@*----------------------------Send a string to UARTInput: s (address of string)Output:None----------------------------*/void SendString(char *s){    while (*s)              //Check the end of the string    {        SendData(*s++);     //Send current char and increment string ptr    }}

lcd1602可以用2个io控制吗

用IIC扩展芯片来控制,SDA和SCL就可以控制8个引脚了,就是串行转并行的思想。

手机上的电量是怎么测量的

一般都用库仑计芯片,电流对时间的积分就是容量了,Q=It,mAH就是常见单位

STM32的芯片类型都是一样的吗?有什么区别呢?

当然不一样了,有主流型,低功耗,高性能型。内核也分很多种,m0347,m33,还有新出的MP1是A7+m4架构的如图:

将二进制转换为BCD码的译码器有哪些?

74HC160是10进制BCD计数器,可以实现二进制转十进制