Git Product home page Git Product logo

Comments (8)

youngkin avatar youngkin commented on July 27, 2024

I opened a PR on this several days ago. Do any contributors have time to have a look?

from go-rpio.

youngkin avatar youngkin commented on July 27, 2024

For those interested in this change while it's waiting to be merged ( #79 ), it's available on my fork at https://github.com/youngkin/gpio. The associated go.mod file has been modified so that it's not necessary to modify imports to use that version of go-rpio.

from go-rpio.

drahoslove avatar drahoslove commented on July 27, 2024

Hi, youngkin,
To be honest, I'm not sure what was the reason for changing the mode.

I was looking at your pull request and also checked the bcm reference manual,
and I realized, that there is a critical bug in the pwm implementation.

I think the pwmRngReg and pwmDatReg values are wrong. Should be 3 4 or 6 7 (probably - table 9.6 on page 141 has wrong values in the Address offset column).

I'd like to fix that first, but unfortunately, I'm not in possession of a working Pi.

Do you think you could be so kind and test that and confirm that my assumption is right?

from go-rpio.

youngkin avatar youngkin commented on July 27, 2024

Yikes! I'll double check that against the reference, and retest

from go-rpio.

youngkin avatar youngkin commented on July 27, 2024

Per the bcm reference manual, page 141, table 9.6, counting up by 4 (i.e., 32 bit words), the register offsets are as follows :

0x0 - CTL
0x4 - STA
0x8 - DMAC
0xC - unused
0x10 - RNG1 (aka pwmRngReg)
0x14 - DAT1 (aka pwmDatReg)
0x18 - FIF1
0x1C - unused
0x20 - RNG2 (aka pwmRngReg)
0x24 - DAT2 (aka pwmDatReg)

Counting up by words (as the code does):

0 - CTL
1 - STA
2 - DMAC
3 - unused
4 - RNG1
5 - DAT1
6 - FIF1
7 - unused
8 - RNG2
9 - DAT2

Assuming my hexadecimal counting is correct, the PWM register offsets are 4/5 and 8/9 as in the code (rpio.go, lines 662-667 in my PR, 640-645 in the main branch). I also verified this against the WiringPi library, lines 150-153. It also uses these offsets.

So, I think the code is correct.

from go-rpio.

drahoslove avatar drahoslove commented on July 27, 2024

So, I think the code is correct.

Aww, that makes sense. I did not realize the addresses are hex, not decimal. That confused me and I thought the number are wrong because there is a lot of errors in the document. I was like "that must be the reason why there are several 'PWM does not work' issues opened."

Apparently, I was smarter 4 years ago than I am now 😄

Thank you very much and sorry for freaking out 👍

from go-rpio.

youngkin avatar youngkin commented on July 27, 2024

It confused me at first too. I had to brush up on my hexadecimal counting to figure it out :)

Thank you for looking at this and my PR!

from go-rpio.

drahoslove avatar drahoslove commented on July 27, 2024

Closed by #79

from go-rpio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.