Revised thinking on STC chips

I have successfully implemented a few projects on the STC 15F104E, a Chinese 8051 architecture MCU.

STC15fF04EThe chip includes EEPROM, and some flexible extensions to the timers which potentially make it more useful than a standard 8051.

I have previously observed that the documentation is poor, and the programming tool is poor.

The project that led to the latest observations was an attempt to implement RC PWM – ON/OFF switch originally on one of these chips as it contained sufficient resources to suit the application. One of those resources was an +/- edge triggered INT0.

The code worked fine, but for only a short and variable period. Essentially, the the main loop was executing fine, the chip stopped triggering the interrupt service routing for INT0 after a variable time from 10s to 1000s… but it ALWAYS stopped working. Cycle the power and the same thing is observed.

Stripping the code down to a minimal test of the interrupt proved the same thing on two 15F104E chips with different engravings (so from different production batches and possibly different manufacturers), and a 15F204E which probably shares the same core.

The code is simple enough, the probe on P3.4 shows the main loop executing and P3.5 shows the ISR called.

   cseg at 0h
   org 0   ; Reset vector
   sjmp init
   org 0003h
   ljmp int0_isr
   org 30h
   setb EX0 ;INT0 int enable
   setb EA ;global int enable
 setb P3.4
 clr P3.4
 sjmp here
 setb P3.5
 clr P3.5

The same code was tested on a STC89C52RC (though the edge trigger is for -ve edge only) and the ISR triggered reliably for an hour… as you would expect.

During this test, I fell foul of a gotcha that I have previously solved. I was using a hardware COM1 to program the chips, and the programming utility doesn’t work properly with it unless I open the port with some other software first… a sign that the STC utility doesn’t set port parameters properly when it opens and depends on defaults that might not suit.

I wasted two days to prove that this was a defect in the chips, and that I should dismiss STC chips in future due to Chinese Quality (bit of an oxymoron sometimes). I am also now wary of buying any products with STC chips in them.

It costs a little under A$1 in 10s whereas the Atmel ATTiny25 is a little over A$1… so it is not much cheaper than a good chip, and the manufacturer provides no tools other than the buggy programmer utility.

Fortunately it took less than an hour to port the code to the ATTiny25 on which it proves to be rock solid of course, sound algorithm, good implementation, and RELIABLE MCU.