User Tools

Site Tools


dev8051:dev8051

Things 8051

Merging all my notes related to 8051-based system development.

My personal code library for 8051 is available at codeberg.org.

Core 8051

Microcontroller/board info.

Board51:stc15w204s (8-pin)

Picture

stc15w204s front stc15w204s back

Block diagram

stc15w204s pins stc15w204s pins

May need proper USB2serial cable (e.g. PL2303-based)

stc15w204s pins

2024/11/11 11:48 · azman

Code 8051

Example codes (in C) for the classical Intel-8051 (mcu51) microcontroller core. Using my1code51 library. Tested using sdcc open source compiler and stc12 device.

Codes for NMK322

Testing IR module and HC-SR04 ultrasonic sensor module.

Testing HC06 bluetooth module , TowerPro MG996R servo & Text LCD.

Testing Base Kit (202425s1).

Testing RFID (FRC522) and OLED (ssd1306).

Code: relay

Testing basic relay.

relay.c
/*----------------------------------------------------------------------------*/
#include "timer.h"
#include "uart.h"
/*----------------------------------------------------------------------------*/
MY1SBIT(DRIVE,PIN20);
MY1SBIT(INPUT,PIN10);
/*----------------------------------------------------------------------------*/
void main(void) {
	unsigned char wait;
	timer_init();
	uart_init();
	uart_puts("\nTESTING RELAY\n");
	DRIVE = 1; /* active low */
	INPUT = 1;
	while(1) {
		if (INPUT==0) {
			uart_puts("-- Switch ON... ");
			DRIVE = 0;
			wait = 3*TIMER_LOOP_1S;
			do { timer_wait(TIMER_VAL50MS); } while (--wait);
			uart_puts("OFF.\n");
			DRIVE = 1;
			while (!INPUT);
		}
	}
}
/*----------------------------------------------------------------------------*/

Code: gtuc51

Test code for the old GTUC51B001 development board.

2024/11/11 11:50 · azman
dev8051/dev8051.txt · Last modified: by azman