This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to simulate an input via PC

Hello!

I have a problem and I don't know how I can resolve it.

I have a starter kit and all the code is in the micro (XC167CI) and I have connected my PC to the starter kit. I want to set and reset an input pin when I push a key of my keyboard PC to simulate a fast interruption.

I have tried it:

		printf(menu);
		select=input();

		switch (select)
		{
			case '1': P2_P8=1; break;
			case '2': P2_P8=0; break;
			case '3': break;


So when I push number 1, the pin 8 of port 2 is set but the fast interruption is not generated. P2.8 is an input.

In keil I have created a button:


define button "ppoAvisoAI",		"PORT2 |=0x0100"
define button "finAvisoAI",		"PORT2 &=0xFEFF"


With that button the fast interruption is going on but with my code (P2_P8 = 1) the fast interruption is not going on. What can I do?

  • I want to set and reset an input pin when I push a key of my keyboard PC to simulate a fast interruption.

    The micro generally cannot actually set or reset its own input pins. For that, you would have to electrically connect one of its output pins back to that input pin, and flip the output to control the input.

    But if all you want is to simulate interrupts, it should be possible to directly set the relevant interrupt flag bit instead.