20230704 Test the virtual serial port of the STC32G experiment box 9.6 (STC32G12K128) development board (in-depth understanding of C language)


20230704 Test the virtual serial port of the STC32G experiment box 9.6 (STC32G12K128) development board (in-depth understanding of C language)
06 Episode 5: Introduction to C language operators and base numbers.mp4
07 Episode 5: C language operators and base numbers Getting Started.mp4
2023/7/4 19:00

The next time I record a video at [Brother Chong]. It is recommended to record under the official version of WIN10 and WIN11. Old test version. Bill Gates will have an opinion when he sees it!

 

ASC code table:

 


0.
https://www.stcai.com/syx
experiment box

STC32G experiment box 9.6
The main control chip uses STC32G12K128, which can be used as oscilloscope, waveform generator, TFT color screen display, OLED 12864, LCD 12864

Code download
Instructions for use STC32G12K128 experiment box-V9.6 instruction manual.pdf
schematic diagram


STC32G12K128 experiment box-V9.6 instruction manual.pdf

Routine 01:

 

#include "COMM/stc.h" //call header file
#include "COMM/usb.h"

char *USER_DEVICEDESC = NULL;
char *USER_PRODUCTDESC = NULL;
char *USER_STCISPCMD = "@STCISP#";
    
//sbit P40 = P4^0; //transistor control pin
//sbit P60 = P6^0; //LED control Pin
//sbit P61 = P6^1; //LED control pin

void sys_init(); //function declaration

void main() //Entrance where the program starts running
{     sys_init(); //USB function + IO port initialization     usb_init(); //usb library initialization     EA = 1; //CPU open interrupt, open the total interrupt.     while(1) //infinite loop     {         if( DeviceState != DEVSTATE_CONFIGURED ) //             continue;         if( bUsbOutReady )                                         {             usb_OUT_done();             //printf("%03.3f\r\n",1.12);             //printf( "%u \r\n",1<<3);             printf("Hello World!");         }         P40 = 0; //transistor pin output low level         P60 = 0; //led4 pin output low power flat



    









            




        P61 = 0; //led5 pin output low level
    }
}


void sys_init() //Function definition
{     WTST = 0; //Set the program instruction delay parameter, assigning a value of 0 can set the CPU execution instruction speed to the fastest     EAXFR = 1; //Extended register (XFR) access enable     CKCON = 0; // Improve access to XRAM speed


    P0M1 = 0x00; P0M0 = 0x00; //Set as quasi-bidirectional port
    P1M1 = 0x00; P1M0 = 0x00; //Set as quasi-bidirectional port
    P2M1 = 0x00; P2M0 = 0x00; //Set as quasi-bidirectional port
    P3M1 = 0x00; P3M0 = 0x00; //Set as quasi-bidirectional port
    P4M1 = 0x00; P4M0 = 0x00; //Set as quasi-bidirectional port
    P5M1 = 0x00; P5M0 = 0x00; //Set as quasi-bidirectional port
    P6M1 = 0x00; P6M0 = 0x00; // Set as quasi-bidirectional port
    P7M1 = 0x00; P7M0 = 0x00; //Set as quasi-bidirectional port
    
    P3M0 = 0x00;
    P3M1 = 0x00;
    
    P3M0 &= ~0x03;
    P3M1 |= 0x03;

    //Set the clock source used by USB
    IRC48MCR = 0x80; //Enable the internal 48M high-speed IRC
    while (!(IRC48MCR & 0x01)); //Wait for the clock to stabilize

    USBCLK = 0x00; //The use of the CDC function requires the use of these two lines, and the HID function disables these two lines.
    USBCON = 0x90;
}


Serial port printing:
[17:57:30.369] Send→1
[17:57:30.384] Receive←Hello World!

[17:57:30.369] Send → 31 
[17:57:30.384] Receive ← 48 65 6C 6C 6F 20 57 6F 72 6C 64 21 

 

 


Routine 02:

 


#include "COMM/stc.h" //call header file
#include "COMM/usb.h"

char *USER_DEVICEDESC = NULL;
char *USER_PRODUCTDESC = NULL;
char *USER_STCISPCMD = "@STCISP#";
    
//sbit P40 = P4^0; //transistor control pin
//sbit P60 = P6^0; //LED control Pin
//sbit P61 = P6^1; //LED control pin

void sys_init(); //function declaration

void main() //Entrance where the program starts running
{     sys_init(); //USB function + IO port initialization     usb_init(); //usb library initialization     EA = 1; //CPU open interrupt, open the total interrupt.     while(1) //infinite loop     {         if( DeviceState != DEVSTATE_CONFIGURED ) //             continue;         if( bUsbOutReady )                                         {             usb_OUT_done();             //printf("%03.3f\r\n",1.12);             //printf( "%u \r\n",1<<3);             //printf("Hello World!");             printf("Current temperature: %.2f\r\n", 11.2);         }         P40 = 0; / /transistor pin output low level



    









            




        P60 = 0; //led4 pin outputs low level
        P61 = 0; //led5 pin outputs low level
    }
}


void sys_init() //Function definition
{     WTST = 0; //Set the program instruction delay parameter, assigning a value of 0 can set the CPU execution instruction speed to the fastest     EAXFR = 1; //Extended register (XFR) access enable     CKCON = 0; // Improve access to XRAM speed


    P0M1 = 0x00; P0M0 = 0x00; //Set as quasi-bidirectional port
    P1M1 = 0x00; P1M0 = 0x00; //Set as quasi-bidirectional port
    P2M1 = 0x00; P2M0 = 0x00; //Set as quasi-bidirectional port
    P3M1 = 0x00; P3M0 = 0x00; //Set as quasi-bidirectional port
    P4M1 = 0x00; P4M0 = 0x00; //Set as quasi-bidirectional port
    P5M1 = 0x00; P5M0 = 0x00; //Set as quasi-bidirectional port
    P6M1 = 0x00; P6M0 = 0x00; // Set as quasi-bidirectional port
    P7M1 = 0x00; P7M0 = 0x00; //Set as quasi-bidirectional port
    
    P3M0 = 0x00;
    P3M1 = 0x00;
    
    P3M0 &= ~0x03;
    P3M1 |= 0x03;

    //Set the clock source used by USB
    IRC48MCR = 0x80; //Enable the internal 48M high-speed IRC
    while (!(IRC48MCR & 0x01)); //Wait for the clock to stabilize

    USBCLK = 0x00; //The use of the CDC function requires the use of these two lines, and the HID function disables these two lines.
    USBCON = 0x90;
}

Serial port printing:
[18:06:02.284] send → 1
[18:06:02.293] receive ← current temperature: 11.20

[18:06:02.284] Send → 31 
[18:06:02.293] Receive ← B5 B1 C7 B0 CE C2 B6 C8 A3 BA 31 31 2E 32 30 0D 
                    0A 

 

Routine 03:

 

#include "COMM/stc.h" //call header file
#include "COMM/usb.h"

char *USER_DEVICEDESC = NULL;
char *USER_PRODUCTDESC = NULL;
char *USER_STCISPCMD = "@STCISP#";
    
//sbit P40 = P4^0; //transistor control pin
//sbit P60 = P6^0; //LED control Pin
//sbit P61 = P6^1; //LED control pin

void sys_init(); //function declaration

void main() //Entrance where the program starts running
{     sys_init(); //USB function + IO port initialization     usb_init(); //usb library initialization     EA = 1; //CPU open interrupt, open the total interrupt.     while(1) //infinite loop     {         if( DeviceState != DEVSTATE_CONFIGURED ) //             continue;         if( bUsbOutReady )                                         {             usb_OUT_done();             //printf("%03.3f\r\n",1.12);             //printf( "%u \r\n",1<<3);             //printf("Hello World!");             //printf("Current temperature: %.2f\r\n", 11.2);             printf("Current Temperature: %.2f, Current Humidity: %.2f\r\n", 11.2, 55.



    









            




        P40 = 0; //transistor pin output low level
        P60 = 0; //led4 pin output low level
        P61 = 0; //led5 pin output low level
    }
}


void sys_init() //Function definition
{     WTST = 0; //Set the program instruction delay parameter, assigning a value of 0 can set the CPU execution instruction speed to the fastest     EAXFR = 1; //Extended register (XFR) access enable     CKCON = 0; // Improve access to XRAM speed


    P0M1 = 0x00; P0M0 = 0x00; //Set as quasi-bidirectional port
    P1M1 = 0x00; P1M0 = 0x00; //Set as quasi-bidirectional port
    P2M1 = 0x00; P2M0 = 0x00; //Set as quasi-bidirectional port
    P3M1 = 0x00; P3M0 = 0x00; //Set as quasi-bidirectional port
    P4M1 = 0x00; P4M0 = 0x00; //Set as quasi-bidirectional port
    P5M1 = 0x00; P5M0 = 0x00; //Set as quasi-bidirectional port
    P6M1 = 0x00; P6M0 = 0x00; // Set as quasi-bidirectional port
    P7M1 = 0x00; P7M0 = 0x00; //Set as quasi-bidirectional port
    
    P3M0 = 0x00;
    P3M1 = 0x00;
    
    P3M0 &= ~0x03;
    P3M1 |= 0x03;

    //Set the clock source used by USB
    IRC48MCR = 0x80; //Enable the internal 48M high-speed IRC
    while (!(IRC48MCR & 0x01)); //Wait for the clock to stabilize

    USBCLK = 0x00; //The use of the CDC function requires the use of these two lines, and the HID function disables these two lines.
    USBCON = 0x90;
}


Serial port printing:
[18:21:38.277] send → 1
[18:21:38.284] receive ← current temperature: 11.20, current humidity: 55.20

[18:21:38.277] Send → 31 
[18:21:38.284] Receive ← B5 B1 C7 B0 CE C2 B6 C8 A3 BA 31 31 2E 32 30 2C 20 B5 B1 C7 B0 CA AA B6 C8 A3 BA 
                    35 35 2E 32 30 
                    0D 0A 


Routine 04:

 

#include "COMM/stc.h" //call header file
#include "COMM/usb.h"

char *USER_DEVICEDESC = NULL;
char *USER_PRODUCTDESC = NULL;
char *USER_STCISPCMD = "@STCISP#";
    
//sbit P40 = P4^0; //transistor control pin
//sbit P60 = P6^0; //LED control Pin
//sbit P61 = P6^1; //LED control pin

void sys_init(); //function declaration

void main() //Entrance where the program starts running
{     sys_init(); //USB function + IO port initialization     usb_init(); //usb library initialization     EA = 1; //CPU open interrupt, open the total interrupt.     while(1) //infinite loop     {         if( DeviceState != DEVSTATE_CONFIGURED ) //             continue;         if( bUsbOutReady )                                         {             usb_OUT_done();             //printf("%03.3f\r\n",1.12);             //printf( "%u \r\n",1<<3);             //printf("Hello World!");             //printf("Current temperature: %.2f\r\n", 11.2);             //printf( "Current temperature: %.2f, current humidity: %.2f\r\n", 11.2,



    









            



            
            printf("%u\r\n", 53);

        }
        P40 = 0; //transistor pin output low level
        P60 = 0; //led4 pin output low level
        P61 = 0; //led5 pin output low level
    }
}


void sys_init() //Function definition
{     WTST = 0; //Set the program instruction delay parameter, assigning a value of 0 can set the CPU execution instruction speed to the fastest     EAXFR = 1; //Extended register (XFR) access enable     CKCON = 0; // Improve access to XRAM speed


    P0M1 = 0x00; P0M0 = 0x00; //Set as quasi-bidirectional port
    P1M1 = 0x00; P1M0 = 0x00; //Set as quasi-bidirectional port
    P2M1 = 0x00; P2M0 = 0x00; //Set as quasi-bidirectional port
    P3M1 = 0x00; P3M0 = 0x00; //Set as quasi-bidirectional port
    P4M1 = 0x00; P4M0 = 0x00; //Set as quasi-bidirectional port
    P5M1 = 0x00; P5M0 = 0x00; //Set as quasi-bidirectional port
    P6M1 = 0x00; P6M0 = 0x00; // Set as quasi-bidirectional port
    P7M1 = 0x00; P7M0 = 0x00; //Set as quasi-bidirectional port
    
    P3M0 = 0x00;
    P3M1 = 0x00;
    
    P3M0 &= ~0x03;
    P3M1 |= 0x03;

    //Set the clock source used by USB
    IRC48MCR = 0x80; //Enable the internal 48M high-speed IRC
    while (!(IRC48MCR & 0x01)); //Wait for the clock to stabilize

    USBCLK = 0x00; //The use of the CDC function requires the use of these two lines, and the HID function disables these two lines.
    USBCON = 0x90;
}


Serial port printing:
[18:30:16.453] Send→1
[18:30:16.459] Receive←53


[18:30:16.453] Send → 31 
[18:30:16.459] Receive ← 35 33 0D 0A 

 

Routine 05:

 

 

Routine 06:

 

 

Routine 07:

 

 

Routine 08:

 

 


References:
http://stcmcudata.com/
https://www.stcai.com/jxsp
Demonstration Video
Experiment Box-STC32G12K128 Teaching Video
Tulong Knife-STC32G12K128 Teaching Video


 

Guess you like

Origin blog.csdn.net/wb4916/article/details/131541334