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

Update CH422G and add a new example #9

Merged
merged 1 commit into from
Oct 18, 2024
Merged

Update CH422G and add a new example #9

merged 1 commit into from
Oct 18, 2024

Conversation

Lzw655
Copy link
Collaborator

@Lzw655 Lzw655 commented Oct 18, 2024

@Lzw655 Lzw655 merged commit 2ca1b78 into master Oct 18, 2024
15 checks passed
@Lzw655 Lzw655 deleted the feat/update_ch422g branch October 18, 2024 06:13
Copy link

@ThermIQ ThermIQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I believe there is a bug in this code with regards to output control of OC0-OC3. These outputs can either be push-pull OR Open Collector. Open Collector is selected by setting corresponding bit in the control register. The specific bit is bit4.

As the english datasheat for Ch422G is likely the worst I've seen in my 40 years of electronic design it took me considerable time, a chinese friend and some magic smoke to figure this out.

The full register map looks like this:

    //
    // Bit:        |    7    |  6  |  5  |    4    |    3    |    2    |    1     |    0    |
    //             |   ---   | --- | --- |   ---   | ------- | ------- | -------- | ------- |
    // Value:      | [SLEEP] |  /  |  /  | [OD_EN] |         |[A_SCAN] |          | [IO_OE] |
    //             |   ---   | --- | --- |   ---   | ------- | ------- | -------- | ------- |
    // Default:    |    0    |  0  |  0  |   0     |    0    |    0    |    0     |    1    |


This is described in the datasheet CH422G datasheet in paragraph 6.1.2

The testcase provided likely works since the electric interface accepts push-pull and the Open Collector drive is not verified as high-Z on 1-as output

@Lzw655
Copy link
Collaborator Author

Lzw655 commented Nov 5, 2024

Hi @ThermIQ,

Thank you for your feedback!

At first, I designed the OC0-OC3 open-drain function (OD_EN: bit 4) according to the CH422G datasheet, but @H-sw123 found through hardware testing that this feature didn’t work and pointed out that the CH422G datasheet was incorrect. The correct data bit sequence is the one used in the current driver.

Additionally, the driver code in ESPHome is also worth referencing.

@ThermIQ
Copy link

ThermIQ commented Nov 7, 2024

Ok, I will try to verify the OpenCollector function later. I'm not the least surprised that the datasheet is wrong

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

Successfully merging this pull request may close these issues.

New Waveshare (b) devices use Different CH422G outputs
3 participants