STC15W401AS 8051 clone Microcontroller series  

  RSS

triform
(@triform)
Estimable Member
Joined: 1 month ago
Posts: 141
05/08/2019 11:26 pm  

Back in the 1990s I did some embedded stuff at a place I worked.  It was Z80 mostly but did do a few 8051 projects.  The 8051 was a joy to work with and the first microcontroller I had ever worked with.  It's been a "few" years since then, and I have moved on to Pic and Atmega based uCs.  About a month ago I saw this on Ali window shopping: STC15W401AS so I dropped a couple in my cart and did the deed. 

They are of course 8051 clones, 5v GPIO tolerant pins, very low power usage (really low),  a running voltage range of 2.4v (more like 2.6v) to 5.5v, 14 GPIO (on the one I have) 1 UART, SPI, 10bit AD, PWM and more.  It does not have I2C, but if needed, that's fairly easy to bit-bang.

My main reason was to see if it would fit a low power need I have for a future project I am in the planning stages for.  Of course, the other equally important reason was to play!

In preparation for the uC delivery, I made sure the sdcc toolset would support them, and it would.  I also noticed Platform.IO has support via sdcc.  So with that done, I just needed to make sure I had a programming cable and I did.  An FTDI, CH340 or the like will work.  No other programmer needed!

So this morning my wait ended and the boards arrived.  I could not wait, so at lunch, I hooked one up and created a P.IO project and cobbled some code together from the internet.  Found an FTDI serial cable and hooked it up, clicked "build" and then "upload" and boom, it worked.  Yet another flashing LED.

Here is the board in action:

IMG 20190805 171324 compress94
IMG 20190805 171315 compress40
IMG 20190805 172008 compress48

It runs at the same speed at 2.7v or 5v.  The power use seems to be @10ma, but will test further on that.

Here are the data highlights and datasheet.

Scott

 


Quote
triform
(@triform)
Estimable Member
Joined: 1 month ago
Posts: 141
07/08/2019 4:07 pm  

I have a small simple blink program for this controller.  I'm building it from Platform.IO using the "platform: intel_mcs51; board: stc15w404as" profile. This uses the sdcc compiler toolset to compile and the stcgal python script to load the hex file to the uC. You will, of course, need an FTDI or other USB to serial cable or device to program it. Remember to reverse the RX and TX lines. RX on cable -> TX on the controller, TX on the cable to RX on the controller.

 

#include <stc12.h>
#include <stdint.h>
#include <stdio.h>

#define LED P1_0 // LED on Blue board with large switch at front.  

// Non timer interrupt based millisec delay based on a 11.075MHz clock.
void delay (int loop_cnt)
{
    int cnt, ocnt;

    for (ocnt = 0; ocnt < 482; ocnt++) {
        for (cnt = 0; cnt < loop_cnt; cnt++) {
        __asm__ ("nop");
        }
    }
}

int main ( )
{
    while (1) {
        LED = 1;
        delay (1000);
        LED = 0;
        delay (1000);
    }
}

ReplyQuote
triform
(@triform)
Estimable Member
Joined: 1 month ago
Posts: 141
07/08/2019 6:07 pm  

Another example. This time an interrupt handler. When the button on the board is pressed, the LED is toggled on and off. There is no debounce in this example.

 

#include <stc12.h>
#include <stdint.h>
#include <stdio.h>

// Simple interrupt sample.

#define BUTTON P3_2 // Button on P3_2 for the Blue board with large switch at front. INT0
#define LED P1_0 // LED on Blue board with large switch at front.  

void exint0 () __interrupt 0 //INT0
{
    LED = !LED; // Toggle LED
}

int main ( )
{
    INT0 = 1;
    IT0 = 1; // Set to falling edge only
    EX0 = 1; //enable INT0 interrupt
    EA = 1;
    LED = 1; // Start with LED off

    while (1) {
        WDT_CONTR |= 1 << 4; // Clear the watch dog timer.
    }
}

ReplyQuote
triform
(@triform)
Estimable Member
Joined: 1 month ago
Posts: 141
07/08/2019 7:49 pm  

Blink example using a timer interrupt. Could be modified to perform PWM or other timed based functions. 

 

#include <stc12.h>
#include <stdint.h>
#include <stdio.h>

typedef unsigned char BYTE;
typedef unsigned int WORD;

#define FOSC 11075000L // CPU freq.
#define T1MS (65536-FOSC/12/6000) //1T mode, 32.274KHz
#define BUTTON P3_2 // Button on P3_2 for the Blue board with large switch at front. INT0
#define LED P1_0 // LED on Blue board with large switch at front.  

static BYTE cycle_cnt = 0;
static unsigned long millisecs = 0;

/* 
   Timer0 interrupt routine 

   Set to run at 32.274khz. 
   Keeps track of millis and has "room" for other function like PWM.
*/

void tm0_isr ( ) __interrupt 1
{
   cycle_cnt++;

   if (cycle_cnt == 72) { // Every 72 counts is one millisec based on CPU clock and divider.
        millisecs++;
        cycle_cnt = 0;
   }
}

void main ( )
{
    AUXR |= 0x80; //T0 in 1T mode
    TMOD = 0x00; //set T0 as 16-bit auto-reload timer/counter
    TL0 = T1MS; //initialize the timing value
    TH0 = T1MS >> 8;
    TR0 = 1; //run T0
    ET0 = 1; //Enable T0 interrupt
    EA = 1;
    unsigned long loc_mills = millisecs;

    // Toggle the LED every second.
    while (1) {
       if (millisecs - loc_mills == 1000) {
           LED = !LED;
           loc_mills = millisecs;
       }
    }
}

ReplyQuote
triform
(@triform)
Estimable Member
Joined: 1 month ago
Posts: 141
09/08/2019 2:37 am  

An update on these boards.  I do like the processor a lot. It's easy to use and has a lot of good functions built it, has a decent toolset and easy to program. I'm not a big fan of the board that this manufacturer made for it. The pads are SO small! It's was a pain to solder and a pain to keep pins in after they are soldered! The chips are listed on Ali and other places for just a few dollars for 5-10. I will make a board and use it for my work.

I have started a motor controller and have it running the BTS7960 motor driver. I'm running it from 16khz to 20khz and it's really quite and not heat at all.  Impressive so far for a 4$+ h-bridge. 


ReplyQuote
Robo Pi
(@robo-pi)
Honorable Member
Joined: 2 months ago
Posts: 509
09/08/2019 4:10 am  

Is this related to the old Intel 8051 Microcontroller?   I have three of these old NMIY-0031 development boards I bought years ago from New Micros.   I'm sure these are quite outdated being older chips and boards. In fact, I was trying to find information on these particular boards a while back and couldn't find anything so I figure they are pretty obsolete.

NMIY-0031 

DroneBot Workshop Robotics Engineer
James


ReplyQuote
triform
(@triform)
Estimable Member
Joined: 1 month ago
Posts: 141
09/08/2019 5:01 am  

@robo-pi

They are newer 8051 core-based microcontrollers.  Faster, with builtin clocks, ISP, and better timers. 

Scott 


ReplyQuote
triform
(@triform)
Estimable Member
Joined: 1 month ago
Posts: 141
10/08/2019 5:53 pm  

Well, I ordered some STC15W408AS IC's yesterday and this morning sat down and laid out a PCB. I will mull over it a few weeks before sending to the PCB house.

Screenshot 2019 08 10 12 44 08

I'm still not grown up yet and will only use the uC in surface mount form 😉  I really have a lot of support TH components and am not in a rush to order and store SM versions as of yet. The ICs aren't too awful to work with, so I will go with them as they are easier to get now.

Scott 


ReplyQuote
  
Working

Please Login or Register