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

Bug in ReadButton_WriteLED and ReadButton_WriteSerial #16

Open
jjflash65 opened this issue Nov 25, 2024 · 3 comments
Open

Bug in ReadButton_WriteLED and ReadButton_WriteSerial #16

jjflash65 opened this issue Nov 25, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jjflash65
Copy link

At first please excuse my bad english cause I'm an old native speaken german who learnd english 50 years ago. So, I think, sentences in grammar and in vocabulary is wrong and I hope you understand nonetheless.

If you initialisize a GPIO-Pin for Input/Output we must use registers PADIER and PBDIER. Stupidly these registers are writ-we-only so we can't do a read-modify-write -back operation.

Your code
PADIER |= (1 << BTN_BIT); // Enable Button as digital input
has function, cause this is the first and only time where you are modifying the PADIER register.

If I modify GPIO-pins (for example driving an I2C data-line, switching between input and output), I only modify an external variable called "PADIER_tmp" and doing every modifying to this variable by afterwards writing to the register

volatile uint8_t PADIER_tmp = 0xf9; // Bits 2 -1 could be keep 00 for future compatibilty

PADIER_tmp |= (1 << BTN_BIT); // set as input
PADIER= PADIER_tmp;
.
.
PADIER_tmp &= ~(1 << BTN_BIT);
PADIER= PADIER_tmp;

Nice greetings
JJ

@cpldcpu cpldcpu added the bug Something isn't working label Dec 23, 2024
@cpldcpu
Copy link
Member

cpldcpu commented Dec 23, 2024

Hi JJ, can you submit a pull request, if you already found the solution?

@jjflash65
Copy link
Author

Hi JJ, can you submit a pull request, if you already found the solution?

Hi cpldcpu, as you know, I'm not the "hero" in english language and I'm surely not the "hero" by doing things in github (and shame on me: I don't know how to do a pull request in github). The solution to the bug is given in the posting (writing the value tu a global variable, do a read-modify-writeback operation to the variable and write the variable value to PADIER / PBDIER).

@spth
Copy link
Contributor

spth commented Dec 25, 2024

If you prefer the old ways: you can also attach a patch to a message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants