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'>http://www.eevblog.com/files/VCG-VTG-AssemblerCode.zip
Forum: http://www.eevblog.com/forum/blog/eevblog-b10000000000-1k-micro-magic/'>http://www.eevblog.com/forum/blog/eevblog-b10000000000-1k-micro-magic/
EEVblog Main Web Site: http://www.eevblog.com
The 2nd EEVblog Channel: http://www.youtube.com/EEVblog2
Support the EEVblog through Patreon!
http://www.patreon.com/eevblog
Donate With Bitcoin & Other Crypto Currencies!
https://www.eevblog.com/crypto-currency/
EEVblog Amazon Store (Dave gets a cut):
http://astore.amazon.com/eevblogstore-20
T-Shirts: http://teespring.com/stores/eevblog
๐Ÿ’— Likecoin โ€“ Coins for Likes: https://likecoin.pro/ @eevblog/dil9/hcq3

Hi welcome to Eevblog number 1024 And yes, you should know the significance of a Thousand and Twenty Four, so rated it much more important than the 1000th video. So I thought I'd do something 1k related one not 1k as in a thousand a thousand Twenty Four two to the power of ten. We have to go a back to the future here. August 1999 I thought you I'd show you an old project I had published Let's go to page sixty, shall we? Tada? Oh no, that's the sorry.

This was actually very confusing. There are two projects in this issue. one is mine and the other is someone else's one. by the way, James Barker is a pseudonym for someone who I won't tell you who, but that's not their real name.

Anyway, it's a video title generator. Here's mine. Here's a name you might recognize: David L Jones And this was a project. a little project that I used to sell in both KITT and built art form was actually very popular at the time.

It inserted a time date over composite video signals, which was a big deal back in 1999 for security and other applications. Anyway, Ah well. I won't go through the whole article I'll actually scan it in and include it down below below for those who want to read the whole thing. but it basically used a Pic16f877a video text generator chip so the Pic16f877a face.

but the 16 F-84 not to be confused with a modern 16 F-84 A that actually are contained one program 1k program words of memory a thousand and 24 not bytes. Because the Pic processors are actually are 14 bit instruction word so it's like 1.8 K but it's actually really 1,024 program words 1k So I Thought we'd take a look at this old project and see if we can compile it again. and there's the one-to-one PCB pattern for those who want to build their own at home. Although, you'll have to scale this video properly, but you could do it kind of.

There's my original prototype which I sent in which Tada I found in the archives there. There it is, that is. Yeah, it's even got the same label with that same original label on it. So they said they did send the the prototype projects back at these magazines, but you had to send it to them too so that they could test it out before they invent it before they publish the thing anyway.

Composite Video in Composite Video out powered from 12 RCC a little 5 volt regulator in there Pic16f54 Delos Semiconductor D S 39 the main crystal and the 32 Kilohertz crystal for the real-time clock. A bit banged as I'll show you in the source code bit banged in I squared C serial I squared C port on this thing and all this wonderful stuff with the time/date overlay. Everything ran in 1k of program memory just. but that's not all.

Two months later in October 1999 I had another one published a follow-up project which was the V V T G as opposed to the VCG was the video title generator. Where is it there? it is Tada Very similar case to this one except a hooked up to a PC 8e keyboard. None of this, you know, modern USB or Ps2 rubbish and it allowed you to insert it. Basically used the same pic16f877a neces like the menu interface on it so this did a lot more stuff than that time date one but this one also fitted in 1k of program memory and you can actually do bigger fonts and stuff like that as well.
so it was quite jazzy. so let's take a look at the source code and see if we can compile it. By the way, when I had the first one there published in August, that was the very last editorial, the very last time that the famous Jim Roe actually edited the magazine and he said no, I'm handing over to our Gramma. Cuddly and well, it lasted a couple of more months as Eletronics Australia before it became EI E.

Well, I still had electronics Australia but it became EA and Gadget Mania and that was the beginning of the end. And like nine months after that, they renamed it it or EA. Today they dropped the electronics Australia title and everyone unsubscribed. Literally everyone unsubscribe from the magazine and they folded like two or three issues later or something like that.

And but basically that was the end. April 2000 Let's say the end of 1999 when I had these projects published was the end of the venerable electronics Australia as we knew it and it had lasted for well if you believe Jim Oh, there you go and you should because he's right 77 years it was going for at that point absolutely under various names radio TV and hobbies and their wireless weekly Anyway, bit of a nostalgia for those Aussies Alright, I Thought it'd be interesting to see if I could still compile my original assembler source code 18 years later after the fact. Is it still possible because here it is: I've got the original source files. Version 1.

That's how I label them VCG Video character generator 1.0 looks like a jump from 1.0 to 2.0 I can't remember the differences. 2.0 a 2.0 be a 2.1 seems to be the latest now. I Do remember that 2.1 A is the version for a pic 16 C 61 ship not the F So I think I used that in production because that chip was cheaper. The CMOS version, the one-time programmable CMOS version was cheaper than the flash program I only used the F 84 for software development I think I think the ones I actually shipped it were the C versions because I didn't include an in serial programming header on there cuz it wasn't like it wasn't easy to program these things back then right? so you know it's not when he having you pick kits and all sorts of stuff you do these days.

Here's all my original assembler code There it is that's got a lot of comments on me. Yay me! Look at that. It's quite comprehensive. so I just want to cut and paste this code into the new MP lab environment or whatever it is and see if we can use it now.

I Don't think I've used MPLAB X Integrator, but I've downloaded this and it's 667 megabytes. I've downloaded and installed it and yeah, it's shocking. Is that or is that yeah? I assume that's the one you can presume. You can just download the command line assembler if that's what you want to do.
but I'm just going to go for broke and install MPLAB X IDE see if they still support the chip and still support just compiling it straight out of the box. 18 years later? let's go. All right. here's the: MPLAB X IDE I'm not an expert on using this, so please forgive me around and whatnot.

but let's I go in and let's create a new project. Standalone project is what we want. Yep, no worries, we don't want any of that rubbish. so we want I believe they're a mid-range pick.

They have different ranges so if you go into the baseline ones there there I think they've got year your tiny ones, your 1012 oh no. 16 C's no, it doesn't it C it doesn't even have the 16 C 61 which I originally use. so let's go into them and it certainly doesn't have the F 84 in there. Tada 84 We have the 84 and the original 84, not just the new 16f 84 I which is just like I think they just used like a new manufacturing process or whatever, but they still.

so there might be very minor differences. I programming wise I'm not sure, but mine was the original 16 F 84 and they still support it and this is one of the good things about Microchip. Hats off to them! They do support legacy products really well, so we'll choose the original 16 F-84 next and we can choose our hardware tools. ICD What are the microchips? starter kits can choose I don't know what I'm gonna try and program it with yet I got no and probably pick chip but I don't have the ISP on there and have to budge something up but we can just choose the simulator so let's just choose the simulator.

for now, we can always change it later and here we go. We don't want to use the pixie compiler Know that? Rubbish. This is what we want so we're gonna choose the assembler and VCR we'll just call it V CG Shall we set as main project? Boom? encode in? Don't care about that, we'll just go and we're in like Flynn There's our device 16 F-84 Okay so what we want to do is new assembly file ASM So I won't find the original file. I'll just get a new one.

just make a new one in the project directory and here we go: VCG ASM There it is and now I can just cut and paste in my code. Okay, so I've just highlighted all my code there from the text file. We'll copy that and well paste it. Bingo! We're in like flee.

We got this new fangled color syntax highlighting which makes it look a lot better. Look, it knows it's comments so they're all green. It knows the defines and it knows the variables and all that sort of jazz. so that is quite nice.

And there's all my assembler code so we can save that and let's try and compile it. One thing I really like is this navigator. look at this VCG ASM Navigator and this has its pulled in all my variables and whatnot so we can go at like cursor loop. we can jump to cut my function in there for cursor loop.
look at that isn't that great. Stable whatever that means. Um, Oh, I squared C There's my I Squared C bus as stable conditions. So here we go.

Here's all the I Squared C routines. So I wrote my own bit bang in I Squared C routine for this because the sixteen F-84 does not have an I Squared C hardware in it. There we go. So I'm using the Troost instruction to set the bits and I Square C start condition and then send by it.

So there's my routine for pass by it to the send buff reg. I like I don't know. forgotten like almost all of this. I used to be pretty good at microchip assembler code, but now it's like it's almost Klingon to me.

Now it's 18 years ago. Give me a break. Yeah, not long after this. I sort of like switch to C and like I never really touched much assembler.

after that it was. You know only very occasional things that I needed to do so. Yeah, I've forgotten more than I've remembered unfortunately. But of course it wouldn't take me long to pick up all this again and get back up to speed.

You know it's just a matter of hours like it's not. You know, we'd days or weeks or anything like that. So anyway, so we've got our Vc g ASM So what I want to do is now. I just want to build it.

Clean build and main project. Let's just hit the button, see if it works arm. We're selected 16 and we're selected our part. The 16 F-84 We've included our source code.

We've only got the one ASM file. No, No, we don't have to link anything. Mean we don't have to do anything. This should work.

Fingers crossed. 18 years later. Come on Microchip, don't let us down. Whoa.

Build. Successful total time. One second. there you go.

Done VCG It's generated. There we go is generated VCG x Production Ax is generated our hex file. there's the command line and that it used slash clear / 16 F-84 Build Production blah blah blah blah blah and VCG ASM was our only file now. It gave us a couple of messages line 78, registering opera am not in bank zero and sure that bank bits are correct.

I don't remember all this year. The memory architecture of the baseline pics is like you have to swap banks and stuff like that if I remember rightly. So if we go up the top, we'll probably find that I mention I do banks here. we go so the originated 0 so it actually starts with address zero and yep, select big One.

There it is there we go. So I'm selecting memory bank one I don't sell it and then I do something else and select being zero I can't remember the architecture off the top of my head. It'd take me a while to get back up to speed on that. But yeah, so that's a register in Operon, not in means I don't know if that was a regular if I got that message back then and it's just something I ignored or whatnot.

Like, it's not an error so it's like just just a message I Guess it's just ensure that the bank bits are correct I'm sure I got it right I knew what I was doing right in the assembler code so it's not an error. It compiled 18 years later with the big MPLAB X environment or 690 whatever Meg of it and it just it simply worked my code. It's generated the production hex file. so if we go up here distribution.
there we go. Distribution: Default production. There's our hex file. That's our hex fault which we can program into our 16 F-84 using whatever programmer you like.

we don't Winner chicken dinner. All right. So the whole point of this video was also to see how much memory I had left I was using. So if we go into memory down here dashboard usage symbols: oh okay, what do I think I'll do is I'll just go in here and debug main project and see what AHA There it is there it is.

Winner winner chicken dinner data I've got zero bytes free Oh Daddy use zero free 68 Yeah I didn't use any data like Ie SRAM and there you go. I've used for 95% I've used 974 program words and I got 50 free. so I don't have much left out of all this source code. I'm not sure if I went like if early versions were you know worse and I went through an optimizer I do recall kind of doing that thinking that I do remember being right on the edge of the 1k like 50 hard heaps.

you know at 53 I probably went through an optimized in a bit to get it down just so that further on, when I was actually selling this product, I can like add the odd feature or tweak a few things and stuff like that you know you don't want to be shipping with a thousand and you know using every single last program word in your actual processor because then you can't fix bugs and insert maybe a little tiny feature or whatnot. So yeah, having 50 bytes free, you know that just gives you some flexibility to fix some stuff. But there you go. I used almost all of my 1k and it compiled fantastic.

Okay, what I've done now is I've taken my other project, the Vtg the Video Title Generator which used the 80 keyboard to type characters in and do video overlay and I've included that. So I created a project for that and here's my Vtd Vtg source code. used the same Pic16f877a display codes. There you go.

So I put that at a specific address in memory right at the end. All right, you've got a right click on here and set that one as main project if you've got multiple projects in here, so we should just be able to compile that Tada build six as full. Of course it did the other one and it looks like we got the same bank error messages here, but there's no errors. There's no errors.

It has generated Vtg production dot hex. Fantastic! and what I want to do now is actually go in and have a look at where is it Windows Debugging: no pic memory views I Want to go in and actually view the program memory and here we go. So let's let's have a look at the program memory and because this is assembler, you've got to remember this right. I'm telling this processor what to do.
instruction by instruction. So the code that I've typed up here should match what's the disassembled code down in here. So if you look at address 0 here, I've I originated my code at address 0. That's what originated 0 there means start is it's the processor reset factor the start of code I'm just in the in the pics it's 0 and my first instruction is clear F Port B And sure enough, down here is clear F Port B it's compiled it and then we're looking at that like the simulated memory there and it's D compiling it and it's exactly the same BC Yet look, you'll see it just matches every single instruction it's like.

And if we go right to the end, can we go right to the end? Here we go a thousand and 24. Ah, let's go to our lookup table that all looks the same haha. Our last one there is seven A So if we go right to the bottom of my code, this is interesting. 7a there it is.

Oh x7 a That was the very last line of my code, but I actually did include so that matches. By the way, Oh X 7a matches that 5f. Everything is you know, a byte for byte, word for word, instruction for instruction Exactly what I wrote in my assembler code because that's the whole point of assembler. Why I've put all these extra spaces in here I think I For some reason I decided that I should just fill the rest of the memory because that was A that was a table that I looked up to do the instructions and I just thought well I'm not using the rest of that memory so you know I might as well fill it with something that I know is going to be a space right? So it like yeah there was some that was know some program reason why I actually just filled the rest of the processor memory with that.

But of course if I wanted to add extra space, if I wanted to use extra instructions, I could have just changed that originated instruction 300 to closer to where I was at the end of memory and I could tweak it just to the last byte there. Yes there. the keyboard code lookups. That's right, it converts the keyboard code in the display code.

Aha, here's another lookup table which was my this is what I'm looking for Oh X I Specifically put that into address 210 hex there and this has all of my menu items. so if you had a looked over here my menus. There you go. This is what my title generator looks like.

you know Vtg Oh once all that text has to be stored in the program memory somewhere and I put that in this table here. so there you go. It matches Vtg oh one version 2.1 etc Copyright 99 and then F1 all the instructions to tell the user what to actually do and they were all in that lookup table there. So I had to expend all of my pressure like a good part of my precious 1k program memory.

Putting in all these strings I mean you know the more strings you have, the more of that 1k that you're chewing up. You've got to store them in there. There are ways to compress and do other stuff if you're really desperate. and for those playing along at home, you want to know how many bytes I had leftover on their video.
Tidal generator used 930 so not as many as the I don't Yeah I used like 970 in the video character generator so got 94 program. words Free you I have a freaking moon on 94 program words All right I think I'll go edit this now because I shooting the video out of sequence video killed the radio star. So does it actually still work after all this time? Well, there's only one way to find out that's to plug it up. I've got this oh one XTS 3202 which actually has a composite video output and sure enough, you turn on the power and there it is on the external screen.

No worries at all. but there's no title text. Um, so that means that the STM chip on here must be working. It's processing the surface mount one under there.

it's processing the video, but we're getting no overlay whatsoever. The menu buttons do absolutely nothing. So I think that might be a difference is my oscilloscope might be generating Ntsc and I think I had the flag set in here for world for the Australian power version. So let's try a No.1 Power video source this hour-long.

Yeah, um, it's actually an Australian. Our video generator quite old, but you know, still works, so let's plug it in handily. We've got a Tada, it works, beautiful and that is gorgeous video. Yes, I'm actually generating a black signal.

so I'm generating a power so I can go hang on there we go. checkerboard that's black. There we go. I got crosshatch.

whatever that is. Yep. Also, well, that doesn't work too well. There you go the older and monochrome color bars.

We can switch those to color and there you go. We get a bit of shimmer in on there, but you know I don't know I Can adjust the burst level on this for example, so that's just all. Yeah. so I don't know whatever looks beautiful? Yeah, oh look at the funky stuff I can do sorry I'm just fine just having a bit of fun with some modes on this puppy.

Neat! Okay so what we could do is we can actually go in there and adjust the time and date and also this title. Um so A we stored a bit of text if you just press yet if is press mode button I don't know why did the happy? you can go in there and you can just increment all this stuff go across. you can increment your date sweet us but there you go. You could go in there and set just a shorter title text now.

I could actually program this with my pet cat 3 of course but hey I've already got this little mini pro our programmer you seen in the previous video and it does pix and it does the sixteen F-84 so I've loaded that file in. let's give it a ball program. Yep. program.

jeez it's pretty slow for 1k Wow Twitter your thumbs says it's done alright. Were we able to program this brand speaking new pic16f877a n-- see if everything worked After 18 years here we go. Whoa yeah, winner winner chicken dinner. Oh by the way, if you're wondering where I actually stored this text up here because this pic16f877a way.
Um so I actually stored it in the Delos semiconductor Das 39 Like you know, 50 128 bytes or something of memory in the of SRAM memory and that was battery back down there off the same battery that ran the real-time clock so over the I squared. C I just stored that video text in there. so there you go I hope you enjoyed that look down memory lane of what I it was capable at. Pretty primitive example of what's capable inside a 1k of program memory.

It actually be an interesting experiment Actually, try to see if we could get a in this case any of the microchip bar C compilers to do that exact same code in 1k you probably could. The modern C compilers are very very good if you're optimizing for code space and stuff like that. but back when they did this I don't think there was any real even like using the best one at the time which was like the Australian high tech C compiler which Microchip eventually bought I don't even think that could do it back in the day because I think I had that noise went. now you know and you paid a lot for the 2k chip versus the 1k chip.

It was like double the cost or something you know and so it added to the cost of the kit and things like that. So I saw that little kit until they in st discontinued like two three years later or something. the chip in there and there really wasn't anything else in the industry that could just take video and video out and then some sort of digital serial interface to do video text overlay. I Know there are these days, but back then this was the only chip on the market that I was aware of that actually did this and it was a real bummer.

There were a lot of people using this chip, but a lot of people upset when they discontinued the thing. Anyway, if you liked that video, please give it a big thumbs up because that always helps a lot. And leave your stories down below in the comments or on the eevblog forum about if you've done some magic in 1k of program memory. We've talked about them in the amp hour before actually doing a contest like the 1k programming contest because it's just like you know, a nice around small value that just lets you appreciate you know, assembly language, our programming and trying to extract the maximum possible stuff from 1k of memory.

I Know this is a fairly primitive example, but you know it doesn't do a hell of a lot, but I was you know, pretty impressed that I managed to fit that in 1k have assembly code without trying too hard. Anyway, So yeah, leave your stories down below. or even better yet, link to a project if you've done something really cool in 1k of memory. So I hope you enjoyed that thousand and twenty fourth video.
I Hope I did something appropriate catch you next time you.

Avatar photo

By YTB

21 thoughts on “Eevblog #b10000000000 – 1k micro magic”
  1. Avataaar/Circle Created with python_avatars Kevin Cozens says:

    Hm… "Copyright TRONNORT"? Someone was a fan of a certain movie back in 1999. ๐Ÿ™‚ The code was assembled not compiled. Was that a typo in the text "VLDEO CLK"? Anyway, very nicely done. Always fun writing programs in assembler for a device with very limited memory. I never got in to PICs due to the bank switching business. I'm working on a project using an AVR with 4K program memory and 256 bytes of RAM. I worked a way to store 4 GPS position reports in that amount of RAM. ๐Ÿ™‚

  2. Avataaar/Circle Created with python_avatars Silicon Robot says:

    Great project with minimum resources. In these beautifull old days people used to be very creative and very "optimization" oriented.

  3. Avataaar/Circle Created with python_avatars Okurka says:

    1kB = 1000 bytes.

  4. Avataaar/Circle Created with python_avatars kvadratbitter says:

    Back when Dave was a young player. ๐Ÿฅฒ

  5. Avataaar/Circle Created with python_avatars Rick Pontificates says:

    Popular Electronics inspired me to become an electronics designer..
    When you TRY to build projects in a magazine and thereโ€™s always a part you canโ€™t get, you learn to design around what you CAN get.

  6. Avataaar/Circle Created with python_avatars James Voakes says:

    I really enjoyed this video! I do find that because storage and memory is so cheap now, programmers (myself included) tend to just not bother too much with optimising for program memory. Look at all the competitions that used to exist on the demo scene. Now not so much.

  7. Avataaar/Circle Created with python_avatars Jon D says:

    VLDEO

  8. Avataaar/Circle Created with python_avatars HayJayDee says:

    Please show us more of your older peojects. It is interesting to see those little but powerfull projects. I think its sad that simple protocols like composite video dies out. Of cause it is useless for anything more modern, but backwards compiance would be so great

  9. Avataaar/Circle Created with python_avatars HayJayDee says:

    I was born too late…. Why does everything today must be so complicated. Such "simple" stuff, which one person can build, is just not needed anymore :/

    Very inspiring video and really nice code architecture if your code works 18 years later. Just amazing ๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘

  10. Avataaar/Circle Created with python_avatars leemekeetja says:

    This is fascinating!

  11. Avataaar/Circle Created with python_avatars steve venroy says:

    I remember those claustrophobic days lol.

  12. Avataaar/Circle Created with python_avatars sjekx says:

    that code was compiled 3 days after i was born wtf

  13. Avataaar/Circle Created with python_avatars Zeta Convex says:

    That's pretty amazing. I'm playing with an STM8, using a home-made library that does a bit of GPIO, delaying, and SPI. The hex file is 1.8K. Can't imagine that I can make it any smaller than that.

  14. Avataaar/Circle Created with python_avatars Richard Smith says:

    That's a custom Netbeans IDE. I would recognize that from a mile away.

  15. Avataaar/Circle Created with python_avatars Trent Jackson says:

    Do more projects. You are an rare Australian like myself.

  16. Avataaar/Circle Created with python_avatars fsr says:

    Of course it compiled! Assembly never changes ๐Ÿ˜€

    I remember that the bank switching was quite annoying. The file registers divided around in banks. Not very comfortable to code. But not the end of the world, either.

  17. Avataaar/Circle Created with python_avatars Accordion And More says:

    Great stuff!

  18. Avataaar/Circle Created with python_avatars Cat Man says:

    If it compiles, it will run ๐Ÿ˜‰

  19. Avataaar/Circle Created with python_avatars Crazyboy formally abcdefg says:

    can we ask what the L of David L Jones stands for?

  20. Avataaar/Circle Created with python_avatars Daishi5571 says:

    Everyone should learn to program on a ZX81 with only 1KB.

  21. Avataaar/Circle Created with python_avatars Mikkel Kroman says:

    And meanwhile you can see MPLAB taking up 3 GIGABYTES of memory.

Leave a Reply

Your email address will not be published. Required fields are marked *