Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interrupt from PC (Possible damage to the Serial Port ?)

Status
Not open for further replies.

Electrix

Member
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);
}
 
:shock: My bet is your LED is toast.

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...
 
Joel Rainville said:
:shock: My bet is your LED is toast.

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...

oh i forgot to mention..i had put an infinite while loop like this
Code:
 while(1)
{
 outportb(port, value);
}

and ti was ruuning Turbi C 3.0 under 16bit MS_DOS
 
Electrix said:
oh i forgot to mention..i had put an infinite while loop like this
Code:
 while(1)
{
 outportb(port, value);
}

and ti was ruuning Turbi C 3.0 under 16bit MS_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.
 
Joel Rainville said:
Electrix said:
oh i forgot to mention..i had put an infinite while loop like this
Code:
 while(1)
{
 outportb(port, value);
}

and ti was ruuning Turbi C 3.0 under 16bit MS_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:

but i suspect the port is gone :(
 
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 :D :D 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;
}
 
Status
Not open for further replies.

Latest threads

Back
Top