Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks for Interrupts bad generated code #136

Open
cparrapa opened this issue Nov 17, 2021 · 1 comment
Open

Blocks for Interrupts bad generated code #136

cparrapa opened this issue Nov 17, 2021 · 1 comment
Assignees

Comments

@cparrapa
Copy link
Member

cparrapa commented Nov 17, 2021

i think there is quite another problem. Blockly picks up the wrong C++ statement causing the interrupt not seen.
\the statement for interrupt in blockly should translate int: attachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE);

The statement should be of the form " attachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE);" .

Issue is that the nano and uno interrupt handling is not that flexible.

to do some Realtime event handling with Otto (and nano) you must have good interrupt handling.

a. the setup should include digitalWrite (BUTTON, HIGH), this has to do with internal pullup resistor. I don't know exactly why, Arduino reference may have more info. However this is not relevant for the attach issue.
b. the interrupt attach should definitely be of the form:
attachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE);
the attach statement which currently is in the bloc does not work for some reason. This one does. I added a buzzer with two tones to check if it really works, it does. I forgot to save that one. I don't know WHY your original attach doesn't work, requires more study or testing.
c. within the ISR you included a statement Read Digital state Pin (BUTTON) = 10 , THAT SHOULD BE 1 , OR HIGH. The 10 doesn't work. This is also not relevant to the attach issue as its inside the ISR which can be anything.

But of course the main thing is b. above, to change the attachInterrupt statement in your interrupt block. There is also info on that in the Arduino reference site.

Perhaps its possible to make two versions of your bloc, in case there is a dependency i am not aware off.

image

@logix5
Copy link
Contributor

logix5 commented Jan 13, 2022 via email

@cparrapa cparrapa changed the title Interrupts blocks bad generated code Blocks for Interrupts bad generated code Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants