I'm busy working on a project and have gathered code from a few sources, mainly from Nigel's pic tutorials.
Basically what my code does, or is supposed to do is as follows:
Using a 16F628 I've setup the INT pin to trigger when it detects a pulse from a external source. This calls a interrupt routine which changes a variable.
In my my loop I check if the variable has changed and increment a counter a flash a LED.
I'm also using Timer2 with a counter so that after 60 seconds, another LED is flashed and the value in the counter is sent out pin RB0 via a serial routine to a serial to RS232 converter to the PC when I display the value using hyperterm.
Ok, so most of this works. The pulse is detected which triggers the LED to flash. Every 60 secs the other LED is flashed.
The problem comes in with the RS232 routine. If I jump directly to the routine and bypass the timer0/int checking and get it to send TEST out it works and it displayed correctly on hyperterm. So I presume the hardware is all working and the serial routine is fine.
What I did have to do is comment out 3 x "call Delay255" routines. (At the bottom of the code) With those enabled it somehow breaks the detection of the pulse and flash LED routine. It only works with one Delay255 enabled? Very odd.
The other problem is once I include the RS232 routine with all my other code garbage gets written out to the serial port. A 0x00 value is written out to the serial port everytime INT is triggered?
I"m going crazy trying to figure out where the problem is.
Hope you can make sense of what I'm trying to accomplish.
I've attached the code.
Is there something basic I"m overlooking?
Basically what my code does, or is supposed to do is as follows:
Using a 16F628 I've setup the INT pin to trigger when it detects a pulse from a external source. This calls a interrupt routine which changes a variable.
In my my loop I check if the variable has changed and increment a counter a flash a LED.
I'm also using Timer2 with a counter so that after 60 seconds, another LED is flashed and the value in the counter is sent out pin RB0 via a serial routine to a serial to RS232 converter to the PC when I display the value using hyperterm.
Ok, so most of this works. The pulse is detected which triggers the LED to flash. Every 60 secs the other LED is flashed.
The problem comes in with the RS232 routine. If I jump directly to the routine and bypass the timer0/int checking and get it to send TEST out it works and it displayed correctly on hyperterm. So I presume the hardware is all working and the serial routine is fine.
What I did have to do is comment out 3 x "call Delay255" routines. (At the bottom of the code) With those enabled it somehow breaks the detection of the pulse and flash LED routine. It only works with one Delay255 enabled? Very odd.
The other problem is once I include the RS232 routine with all my other code garbage gets written out to the serial port. A 0x00 value is written out to the serial port everytime INT is triggered?
I"m going crazy trying to figure out where the problem is.
Hope you can make sense of what I'm trying to accomplish.
I've attached the code.
Is there something basic I"m overlooking?