Notifications
Clear all

Using a pin to signal another pin

68 Posts
7 Users
0 Likes
3,890 Views
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@will Like I said, that is built into the boards, and I also more or less said it's just me being picky. My most recent work experience involved high performance so looping code was never used, everything was task based.

Many people use the Arduino timers to create software interrupts, and "Paul McWhorter" has some helpful videos, for example:

Tutorial for Programming Software Interrupts on Arduino

Maybe this will satisfy your needs?


   
ReplyQuote
(@mike-parsons)
Member
Joined: 5 months ago
Posts: 15
 

Hello again. Because I'm quite new to this stuff, I may well be missing your point completely, in which case, I apologise if  I'm wasting your time. I also note that this is quite an old post and you've probably solved it by now. I think I may have been grappling with that very problem for a few weeks now. Eventually, in desperation I just connected an I/O pin directly to the interrupt pin. Setting the I/O pin high (or low as required) triggers the interrupt. It feels wrong, but it solved my particular problem and let me finish my project. I intend to post that project as soon a I suss out how , not because I need help, but that method is asking me more questions than I  have answers for.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6984
Topic starter  

@mike-parsons My original question was if there was an equivalent to the 'signal()' statement in PL1. Since there was not then the idea of using one pin to 'signal' an ISR on another pin was floated. The downside is that technique uses 2 pins. I will wait to see your project before speculating further.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@mike-parsons)
Member
Joined: 5 months ago
Posts: 15
 

I certainly think I didn't understand your question (sorry). I think I'll just back away gracefully from this topic. As for my little project, I'm really starting to feel that I've managed to find a solution for a problem that doesn't exist.


   
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

I've only skimmed this conversation, but the ESP32 docs say that each core has two software interrupts, which in theory should do what I think you want. But they can only be used on the core they're on, so you can't trigger from one core and have a handler run on the other core. Otherwise you'll have to look at FreeRTOS or doing fancy stuff with flags.

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/intr_alloc.html


   
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

On second thoughts, that documentation is confusing me. So I'm probably 1000% wrong and you should ignore me. 😁


   
ReplyQuote
 dw
(@dw)
Member
Joined: 3 years ago
Posts: 15
 

Posted by: @zander

I am thinking of using an output pin of one process to signal another process to do something via it's input pin. I plan on using the attachinterrupt mechanism but am wondering why there is no software equivalent to what I want. Something like signal_interupt(interrupt#) would be nice, I know I can just hit a pin that is configured for an ISR but that still uses up pins, I was hoping to NOT use additional pins, sort of a software pin maybe. So far my research has not found anything but maybe I am not using the right word(s)

 

I see others have responded to this - so you may already have the answer you need.

But my first response would be this.

The MCU has a special register dedicated to every IO pin

So when an interrupt is executed for the state of a pin - the MCU is not reading the pin - it is reading the state of that pin's register.

But one does not have to use an actual hardware pin with its associated register

One can simply use any register one wants to use as a register dedicated for the interrupt.

So one could declare a BIT variable to be used as a FLAG

A register will then be exclusively dedicated to store whatever the state of that BIT variable happens to be.

An interrupt can then be based on reading that register

In such case - an IO pin does not have to be involved in the process

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6984
Topic starter  

@dw How do you associate a bit variable to a hardware register?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 dw
(@dw)
Member
Joined: 3 years ago
Posts: 15
 

@zander 

High zander - and Merry Christmas! :-]

 

From what I read of his post - he was thinking he needed a pin to provide a flag for some kind of program state-change.

.

My response was to let him know - he doesn't have to use a pin for that.

In such case - he would not need a hardware register

 

However - it can be done.

A hardware interrupt routine could also be used to toggle a BIT variable register

That registers state would persist until it is programatically flushed

That register could then be used at any time he wants to use it - as the FLAG for some subsequent state-change in his program.   

In that case he would be associating a hardware register with a BIT variable register - if that is what he needs.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6984
Topic starter  

@dw Show us the code, I have no idea what you are talking about.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 dw
(@dw)
Member
Joined: 3 years ago
Posts: 15
 

@zander 

Wouldn't a Dual Hex Inverter or a Dual NAND gate work also for polarity switching of that LED?

 


   
ReplyQuote
 dw
(@dw)
Member
Joined: 3 years ago
Posts: 15
 

@zander 

We know an interrupt routine can be based on a pin state change.

But once that interrupt is triggered - what do we have that routine doing?

Perhaps it sets the state of a BIT variable to HIGH

 

Now that BIT variable will remain HIGH until a command is run to set it LOW

As long as it stays HIGH - its state is now available any time we want to check to see what it is.

 

So lets say our hardware interrupt routine sets that BIT variable HIGH

At any time within our MAIN program we can check it

And when we check it - we find it is HIGH

Based on that condition we can perform some subsequent action.   


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6984
Topic starter  

@dw I see you have still not provided a realistic solution to what you proposed. Show us the code that does what you said at https://forum.dronebotworkshop.com/help-wanted/using-a-pin-to-signal-another-pin/paged/3/#post-44747

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6984
Topic starter  

@dw

We know an interrupt routine can be based on a pin state change.

But once that interrupt is triggered - what do we have that routine doing?

Perhaps it sets the state of a BIT variable to HIGH

 

Now that BIT variable will remain HIGH until a command is run to set it LOW

As long as it stays HIGH - its state is now available any time we want to check to see what it is.

 

So lets say our hardware interrupt routine sets that BIT variable HIGH

At any time within our MAIN program we can check it

And when we check it - we find it is HIGH

Based on that condition we can perform some subsequent action.   

Yep, that's what most of my ISR routines looked like. However, your regurgitation of the manual does nothing to explain how, as you said, you can do that without involving a pin, just some 'so far' mythical register. SHOW US THE CODE!

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
 dw
(@dw)
Member
Joined: 3 years ago
Posts: 15
 

@zander 

If I had a project which required this process I would be happy to share the code.

However - if I remember - there is a DroneBot video on interrupts

And if I remember - he toggled a BIT variable as part of interrupt routine.

So the concept is shown there - if you want to check it out.

BTW:  There is no need to get aggressive!

This post was modified 4 months ago by dw

   
ReplyQuote
Page 3 / 5