EEVblog #b10000000000 - 1K Micro Magic - Page 1
Forum section: electronics / general

author: EEVblog
author_rank: Unknown
timestamp: September 18, 2017, 11:32:09 pm
content: What can you fit in 1K words of microcontroller program memory?Dave takes a look at two old projects of his published in Electronics Australia magazine using a PIC 16F84 with 1K of program memory.Will the assembly language code still compile first go in MPLABX after 18 years?Assembler Code Download:http://www.eevblog.com/files/VCG-VTG-AssemblerCode.zip

author: alexanderbrevig
author_rank: Frequent Contributor
timestamp: September 19, 2017, 12:00:51 am
content: Nice!

author: Tek_TDS220
author_rank: Regular Contributor
timestamp: September 19, 2017, 01:32:39 am
content: Very entertaining. Yes, Microchip supports their parts for a long time. MPLAB X is huge and takes a long time to startup, but it is extremely capable. There are people who complain on the Microchip forums, but I like MPLAB X a lot. It's the main reason I use their parts. By the way, you can turn off the specific 'bank' warnings if you want.I've written several complete projects in less than 1k words in assembler, but it was a long time ago. I did a 50 MHz frequency counter, for example. The toughest part of that project was building a stable, high-gain, broadband preamp with input protection. The code was easy. I still do some assembler, but only for time-sensitive loops. Programs written in high level languages are much easier to decipher after 10 years.

author: jaromir
author_rank: Unknown
timestamp: September 19, 2017, 07:37:20 am
content: Few months ago I completed project to fit into 1kB of code (not 1023 words, but 1023 bytes) and entered it into 1kB challenge ran by Hackadayhttps://hackaday.io/project/18445-brainfcktorit has very spartan user interface, but you can actually enter and run program written in Brainfuck, as well as observe its results. The most challenging part was cramming bitmaps for letters/numbers/symbols into the 1k, so I had to make some awkward bit shuffling here and therehttps://hackaday.io/project/18445-brainfcktor/log/50032-new-start-character-generator-tables-in-144-bytesbut at the end I managed to cram everything few bytes under 1024 limit.This project won grand prize in the projecthttps://hackaday.com/2017/01/13/1-kb-challenge-and-the-winners-are/

author: HwAoRrDk
author_rank: Super Contributor
timestamp: September 19, 2017, 07:42:01 am
content: Did a project a few months ago (nothing exciting) with an ATtiny13A where I used 1018 bytes of the 1KB flash memory. Wasn't expecting to cut it so close, but, you know... self-inflicted feature creep.Happened to find a bug in the program a few weeks later, and had to add another line of code - 1020 bytes! Hopefully no more will be found...

author: Halcyon
author_rank: Unknown
timestamp: September 19, 2017, 08:14:25 am
content: Ahh the good old Ozemail member's webpages. For those wondering what Dave's webpage (silk-screened onto the PCB looked like):www.ozemail.com.au/~dljones

author: JTR
author_rank: Regular Contributor
timestamp: September 19, 2017, 08:20:22 am
content: Quote from: wilfred on September 19, 2017, 12:18:53 amOh, that nearly made me cry. Hopefully I'll be back.

author: ggchab
author_rank: Frequent Contributor
timestamp: September 19, 2017, 08:41:09 am
content: Nice videoI made a metronome with a PIC16F84, 3 seven segments displays, 3 keys and a speaker. It still works. Only 12 words of program memory and 2 bytes of RAM left ! It has 64 bytes of data EEPROM where working values are saved.Really wondering if this could have been written in C.

author: EEVblog
author_rank: Unknown
timestamp: September 19, 2017, 10:19:47 am
content: Quote from: jaromir on September 19, 2017, 07:37:20 am

author: jonovid
author_rank: Super Contributor
timestamp: September 19, 2017, 01:04:59 pm
content: Video genlock was the holy grail of DIY video in the 80s IMO. its the electronics genius that got his old C64but most-likly Amiga to put text on to his VHS home videowe all had a go, at it,at one time or anotherin the 80s.Quote from: wilfred on September 19, 2017, 12:18:53 amsad day when EA lost it! -so now I get to know why EA disappeared.

author: Barny
author_rank: Frequent Contributor
timestamp: September 19, 2017, 01:16:32 pm
content: The funny thing is, that I am listening to TheAmpHour episode 236, where Dave is mentioning the voice recognition chip video he did.And this chip is a 1K microcontroller.The funny hing is, that in this episode Dave says that he want to run a 1K contest.(I'm a bad programmer, but it would be fun to see the projects)

author: NivagSwerdna
author_rank: Super Contributor
timestamp: September 19, 2017, 01:27:01 pm
content: Very nice project.It's really simple STV5730A and a small PIC but the project execution is nice.... nice PCB with informative silk screen, nice box, documented to the level of a published article.Most of my projects never quite get finished, certainly not to that level of detail

author: Kleinstein
author_rank: Super Contributor
timestamp: September 19, 2017, 01:39:47 pm
content: For ASM code 1 K words is already a relatively long program. I guess all my ASM programs were below 1 K, though there is one (a frequency counter) where I reached the 1 K HW limit before all planed feature were complete - so RS232 HW but no SW.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: September 19, 2017, 02:00:01 pm
content: I wonder if the reason why that ST video character chip got discontinued was because the early '00s was when sales of VCRs and other analogue consumer video equipment started to decline. Products with OSDs like cable and satellite boxes were going all-digital, with more sophisticated hardware, so there was no demand for such relatively simple chips any more.

author: ryanmoore
author_rank: Contributor
timestamp: September 19, 2017, 06:28:40 pm
content: By the mid-late 90s most TVs were using all-in-one microcontrollers to control everything - weird niche parts that did everything from decode teletext to handle the IR remote control, including generating the OSD, so there wasn't the need for a separate chip any more.If you go back 5 years then it was all separate chips - a microcontroller, a teletext decoder, a video switch matrix, an OSD chip, etc...

author: rgunee
author_rank: Newbie
timestamp: September 19, 2017, 09:08:01 pm
content: Hi DaveLove that you celibrate episode 400h more than 3E8h!I always enjoy watching your videos but this episode really hit a nostalgic bit for me as the PIC16C84 really got me started in combining electronics and SW back in the days, especially since I too did a bunch of video projects, like my video gamesPIC-PongandPIC-Tetris(published on my homepage and also the "PIC-List" back in 1998) which both generated a video signal in software only using two resistors and of course most of the 1k memory in the PIC.Tetris in action:Schematic for the game system:Keep up the good work.

author: thm_w
author_rank: Super Contributor
timestamp: September 19, 2017, 10:35:15 pm
content: I'm sure Dave is just trying to be funny and fit with the theme of the episode, but, an 800MB download for an IDE that supports 20 year old parts is completely reasonable.Thats less than 5 minutes to download, even on an Australian connection.Visual studio is over 8GB for the pro edition, Xilinx latest tools are over 20GB and probably don't even support the older devices.

author: niclas@hedhman.org
author_rank: Newbie
timestamp: September 20, 2017, 04:57:35 am
content: Gosh, this episode is lighting up memory lane like Las Vegas. See below; PIC processors had a hardware bug in design 1997 and earlier.This doesn't qualify for 1K project, but I can't wait another 1024 episodes for the 2K opportunity.In 1997, I built a remote I/O device (two 0-10V analog in, two 0-10V analog out, 8 DS1820 temp sensors, a few digital I/O) around the PIC16C73, which was a monster compared to the very popular PIC16F84. 2kWord and 192 bytes memory, ADC, PWM and even an UART.On the UART, I had something called EXOline (similar to Modbus) protocol over RS-485, which had up to 240+ bytes packets, so those had to be decoded in-flight (none of that buffering rubbish).Then the 1-wire protocol, which held the individual 8 device addresses in memory (64bytes). Oh, and I2C (EEPROM with calibration data) and SPI (don't remember for what) interfaces of course, bit banged.I had to optimize all this quite significantly for, a) not enough stack levels, b) to get under the 2kWord boundary, and c) the 192 bytes available. I recall I had 1 bit free RAM (of course marked "future use") and something like 50 words of program memory left.But the kicker on that was that I found a hardware bug, and I could point them to exactly what happened and a software work around for chips already in the field. MicroChip engineering was extremely grateful and granted me "volume price for life" and a batch of 100pc 16C73 as a token of appreciation. They let me know later that the bug was fixed and rolled out during 1998.I also find it remarkable that I and my team found exactly the same problem (UART and Timer interrupt on same clock cycle) in the early 8031 (of (C)1980 design, fixed in (C)1982). The difference was that Intel insisted on that the problem didn't exist and it never existed, even when presented with proof. Just a coincidence that one of us noticed the (C)1980 on the SDK evaluation board and went to exchange it with a (C)1982 and problem gone.MicroChip clearly wins over Intel in terms of servicing their engineering customers.What was the bug? If there were two interrupts (I think it was Timer and UART) on the same clock cycle, only one return address would be pushed on the stack, but both interrupt routines would be called.Software workaround? I don't recall the details of that, but it ended up consuming one stack level (big deal, since we only have 7 stack entries, for both ISR and CALL).

author: Rolo
author_rank: Regular Contributor
timestamp: September 20, 2017, 06:15:48 am
content: Great video. I also started with pic's. My first project that really went in "production" was a controller for a duct valve in my house. It was triggered by an action in the kitchen (opening the cooker hood), it also knew if the valve had made a full turn by reading a optocoupler.Great times. It was based on a 16C84 and worked from 2001 until 2009.

author: Ian.M
author_rank: Super Contributor
timestamp: September 20, 2017, 06:29:01 am
content: @Niclas,Huh?The standard midrange PIC architecture used in the PIC16C73 and PIC16F84, doesn't have vectored interrupts. If two interrupt sources trigger in the same cycle both interrupt flags should be set. If any interrupt flag is set, and not masked by the corresponding interrupt enable bit, or the peripheral interrupt enable bit or the global interrupt enable bit (GIE), GIE is cleared to mask further interrupts and the code at the interrupt vector (0x004) is called as if a CALL instruction had been inserted before the next instruction. The return address stacked is the next instruction. Execution transfers to the ISR and the application code must poll the interrupt flags to determine which interrupt(s) to service. Because GIE is cleared the ISR cant be interrupted, (unless the programmer is an idiot and sets GIE in the ISR). The ISR is then exited by a RETFIE instruction which does the same as a normal RETURN + sets GIE. If any interrupts are still pending, the next main program instruction address is stacked and the ISR reentered before the next main program instruction is executed, so an unserviced but enabled interrupt will hang the main program (unlike AVRs).There is no way the bug could be as you describe. Perhaps 20 years later your memory is a little fuzzy.There was a well known bug with clearing GIE to disable interrupts. If an interrupt was triggered in the instruction that cleared GIE, the ISR would be entered, and the RETFIE would set GIE again, which meant you had to use the code:Code:di: bcf INTCON, GIE ; Disable interruptsbtfsc INTCON,GIE ; Did it work?goto di ; NO, so try againto actually disable them successfully.To set everyone's mind at rest, Microchip fixed the GIE bug before the midrange FLASH memory parts so the above code isn't needed for any PIC10/12/16 part with a F in the part number.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: September 20, 2017, 09:25:12 am
content: Quote from: Kleinstein on September 19, 2017, 01:39:47 pmMany years ago I did a project on a 16C77 which used pretty much all 8K of ROM and all the RAM (plus a couple of registers in unused peripherals) , all in assembler, in a PLCC package that you had to unsolder to update the firmware. That was fun.....

author: 22swg
author_rank: Frequent Contributor
timestamp: September 20, 2017, 09:52:43 am
content: Thumbs up Dave, Back in the day (2000's ) My .asm was not as well constructed , but it worked... I even had a PIC16F84 Greenhouse watering timer project published in EPE mag here in the old country. still occasionally do .asm but i am well into PIC24 and MPLABX now . (well past my 3 score years and ten !)