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

Any write operation to the REG_IRQ_FLAGS cleans all flags, not just the ones where 1 is written #7

Open
kubelvla opened this issue Aug 18, 2020 · 3 comments

Comments

@kubelvla
Copy link

I have been trying to get the CRC check working properly, and found two issues. The first one is already addressed here in the pull request #2 .

The other one that prevents the code from detecting the CRC check failures is that any writing operation to the REG_IRQ_FLAGS register (even writing 0x00) causes all the IRQ flags to be reset, not just the intended ones. In the example receive function, there is this line that is supposed to clean only the RxDone flag:

writeReg(REG_IRQ_FLAGS, 0x40);

but actually it cleans all the flags, so you never detect the CRC error. A quick fix is to read the flags before doing any writing to that register. But what seems to me to be a greater problem is the fact that the datasheet says "Writing 1 resets a flag", and in reality, all flags are reset. Even the example code follows the datasheet. I have two RPI Lora Hat boards, and they both behave this way.

@kubelvla
Copy link
Author

To demonstrate this, I print the register contents before and after the write operation:

boolean receive(char *payload) {
    byte irqflags = readReg(REG_IRQ_FLAGS);
    byte check_reg_value = 0x00;

    print_byte(irqflags, "REG_IRQ_FLAGS (before write)");

    // clear rxDone
    writeReg(REG_IRQ_FLAGS, 0x40);

    check_reg_value = readReg(REG_IRQ_FLAGS);
    print_byte(check_reg_value, "REG_IRQ_FLAGS (after write)");
    
    ....

And I get this output:

The byte REG_IRQ_FLAGS (before write) contains: 70, which is:
7 6 5 4 3 2 1 0 
0 1 1 1 0 0 0 0 
The byte REG_IRQ_FLAGS (after write) contains: 0, which is:
7 6 5 4 3 2 1 0 
0 0 0 0 0 0 0 0 

This was a case where there were some wrong bytes, so the CRC check flag is also on.

@bonedaddy
Copy link

hi @kubelvla did you ever figure this out? thanks.

@kubelvla
Copy link
Author

Hi, for my purpose, I just have to read the register contents before writing to it... It is just not that you clear one flag and later read the others, you have to store the whole register for yourself and then clear it...

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