For providing an interrupt signal to the PIC I wrote a small program in C. Now the problem is when I executed it the first time..it went ok..ie: woke up the PIC from sleep. I then connected an led to this Transmit Pin of the Serial Port (9 pin) and had accidently connected it directly to the LED..no resistance is between. After that when i tried...it did not work at all !
Could there be a possible damage to the port ??
Here's my code:
Code:
#include <stdio.h>
#include <conio.h>
void main()
{
int port = 0x3F8;
char value = '1'
outportb(port, value);
return(0);
}
That code won't work for several reasons, the most obvious one is that your program quits right after writing to the port, so you get your signal a few ms at best.
Assuming you are doing this on Windows, you might have trouble under Windows NT/2000/XP using just standard C library function calls. Using the Win32 API would be wiser. It should work fine on 95/98/Me though.
Is outportb a standard C library API call? I know of _outp to output a byte to a port...
That code won't work for several reasons, the most obvious one is that your program quits right after writing to the port, so you get your signal a few ms at best.
Assuming you are doing this on Windows, you might have trouble under Windows NT/2000/XP using just standard C library function calls. Using the Win32 API would be wiser. It should work fine on 95/98/Me though.
Is outportb a standard C library API call? I know of _outp to output a byte to a port...
Good. Have you tried another LED (and a resistor)? Check the voltage swing you get on your port. I know I get +/-10V on mine. Calculate a suitable resistor value, and try again. I think your code should work under real 16 bit DOS.
Good. Have you tried another LED (and a resistor)? Check the voltage swing you get on your port. I know I get +/-10V on mine. Calculate a suitable resistor value, and try again. I think your code should work under real 16 bit DOS.
yeah..i tried that..I took a CRO.. all i get is a negative swing of of about 9-10V negative..I know the LED is fine cause I tested it again with a sepaerate voltage of 5 V ..and yes i did connect a 1K in series this time :lol:
Don't worry, your port is fine .
You can't normally damage the serial port (RS-232). It can stand shorts, voltage spikes and maybe external voltage on it's output. Even the LED should be fine, because serial port can't deliver more than 5~15mA of current.
Your problem has to be elsewhere.
Great..Now it's all in place ! Everything is working fine I installed another version of Turbo C 3.0 , ran in under true MS-DOS 16bit mode (my OS a 32 bit WinXp) and now it's working !
I now get a single low to high transition which in turn wakes up the PIC & does the ISR...This is just great..my first program to wake up the PIC from PC is successful.. 8)
Just for the record, here's my code :
Code:
#include <stdio.h>
#include <dos.h>
int main(void)
{
int port = 0x3F8;
int value = 4;
outport(port, value);
delay(500);
printf("Value %d sent to port number %d\n", value, port);
return 0;
}