Thanks wp, sorry about the delay - in my situation things can completely occupy me around the clock when it goes bad, or I'd have been back sooner.
- I'd like to stick with an interrupt since that is how I initially thought of this. Later I'll worry about how to do it on other input types but it's good to know that option exists, so thanks for the response.
- OK, the circuit is set up on PORTD for the LCD and functions perfectly, in the hardware on the breadboard; It's better than before, no more board twisting to make some unknown critical connection to kick start it again so there was even that benefit to rewiring some. There are only 6 connections necessary from the LCD module to µC PIC chip.
- My problem I need to focus upon is the interrupt code. The situation for care giving is overwhelming and prevents my normal self going off on a million tangents I find interesting. Under the circumstances, unfortunately having that priviledge is not feasible if I have any hope to finish soon. Here's where I'm at and in sore need of help... I have two program versions. One working like before with LCD on PORTD. The other with this additional interrupt code which caused a failure and only seems to make it up to leaving the LCD initialized. Here is the very basic code and it is where I really need help since I still can't quite get my arms around interrupt coding.
I have this in the beginning of my main program, before it enters another while(1) loop for continually updating the LCD's correct time:
Code C - [expand] |
1
2
3
4
5
6
7
8
9
| TRISB = 0x01;
INTCON.GIE = 1;
INTCON.INTE = 1;
INTCON.PEIE = 0;
OPTION_REG.INTEDG = 1;
while(1)
{
table[0] = '0';
} |
My understanding (which may be wrong) is that an infinite loop must follow the initialization of the interrupts in the main program, although I don’t quite get how, if executed sequentially (or is while work in parallel with the rest of the code?) it will get beyond there executing through the code … table[0] is just some chance character I have defined which is constant,and I thought it best to put something inside the while(1). Then I have this exact code in my tiny interrupt routine which is in the last lines of code following the main program:
Code C - [expand] |
1
2
3
4
5
6
7
8
9
10
| void interrupt(void)
{ //RBO/INT Interrupt
if(INTCON.INTF == 1)
{
flag=1;
INTCON.INTF = 0;
}
} |
Can you see any problems? All I need is for the 16f877A ISR-related-code to set an integer = 1 which I named flag, and then go back to work in the main program.
- On the suspected design flaw and distances, etc. All the electronics is going inside a (4x6x3 inch) 10x15x7.5 cm project box, from 4 breadboards I can't wait to pull apart, and my analog circuit we can call the 'sensor' or really 'sensorplus' has actually very clean output. I'm sure I didn't give that impression or maybe exaggerated a bit - when I should have explained better especially to be respectful to anyone kind to help. The comments I made about the signal should have been (a little embarrassingly) that my sensor circuit has a great signal capability except really I didn't want to deal with adjusting it since it was a big time sink already, and I have it running around 4V. It's actually quite stable and very clean and decoupled from the 'probe' part. It was quite complicated for me since before this foray into PIC, that was actually going to be the project,. I realized I wanted to record the times of the events - and that little detail forced me into the uC world. If there is a design flaw it is that the PIC is only being used as a RTC event recorder and my 'sensor' circuit actually uses analog logic to flip a few relays/alarms, when the PIC could have done this more easily had I begun with it. To be bluntly honest, I learned the 'electronics' for the 'sensorplus' circuit (initially envisioning the project in analog) oblivious to realizing the easy of ability for me to create a MCU based project; I didn't know the difference between analog and digital electronics initially. For that matter, I wasn't aware that I could get one of these nifty programmers and program my own smart chip... 'nuff said...I've progressed since then. As for optocouplers, they are probably not necessary although it certainly is another option to connect to the PIC (and I've got three different type some in use already, but all performing analog circuit functions).
Anyway, can you kindly help me clean up the interrupt code so it actually services by setting my integer 'flag = 1' when being serviced?
Thanks!!!
Mex