16F877 Programming (newbie)
OK, let me admit something right up front. I'm an analog cat in a room full of digital rocking chairs. I've been doing stuff from audio through microwave all my engineering and teaching career, but this is my first foray into microcontroller programming ever. Please be gentle with my stupid questions.
I also admit to having a moderate command of Dartmouth Basic, but have absolutely no experience with my brand new PicBasic Pro Compiler, programmer, Lab X1, assembler, or machine language. None whatsoever.
However, I have a project that will lend itself nicely to a uC solution I believe. It is a simple audio switching panel that accepts audio from/to up to three transceivers, a couple more receivers, four analog microphone inputs and all that stuff ... more later, but if you want to see it, please click www.rstengineering.com/picpro
The basic question is this...all those pushbutton switches you see control the leds you see (and by extension the audio channel they represent) in a simple sequence of blue, green, blue & green, all off. The logic to do this in PBasic is quite simple. However, I have just about 40 inputs/outputs and that is a bit much for a through-hole uC, especially as most of the time they will not be doing anything. The device generally goes at least ten minutes and sometimes up to an hour without any of the buttons being pushed.
So, given that the inputs/outputs are MOSTLY binary (on or off) and fairly stable, I want to store the data in the onboard flash memory for a couple of reasons. One is that I want to refresh all of the outputs once per program cycle on the off chance that something burps and turns off an on or on an off. Two is that I want the device to come up in the same manner that it was turned off. (Turn on and turn off are from another power switch in the vehicle.)
So it comes down as to how to "read" a digital 8 bit byte bit by bit or "write" a digital byte bit by bit. That is, if I have eight variables and each bit of the byte represents the condition of one of the 8 variables, how do I assign the value of the variables as a function of the associated bit being high or low? How do I rewrite the byte if one or more of the bits changes?
Before I go making wrong assumptions, I have sort of deduced from the ops manual for PBP (not exactly a literary gem) that (a) you have to define each variable before you use it and (b) a BIT is binary, a BYTE is octal, and a WORD is two bytes in hexadecimal. Yes?
There must be a common name for this sort of process, and if I knew what the name was I could have searched this message board for the name. Sorry to have rambled on so long.
Later questions will address external storage/output of the data, voice recording, and all the rest of the stuff. However, I want to get a basic loop programmed before I do anything else.
Thanks for reading all this drivel.
Jim
1 Attachment(s)
Sorry, Didn't See The Attachments Option
Rather than go to an offsite web page, I'll attach the file to this reply. Sorry for the hassle; I'll get the hang of this soon.
Jim