Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdyscout committed Nov 4, 2022
1 parent 9d81802 commit 5c25f36
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Supports Microchip 16bit [MCP3461/MCP3462/MCP3464/](https://www.microchip.com/en
## Supported Boards

This project is set up to be build with different MCUs, but I am not able the test each of them.
Personally I use the SAMD most, so this should be the most stable code.
Personally I use the SAMD21, so this should be the most stable code.

### Introduction

Expand All @@ -23,29 +23,15 @@ const uint8_t pinMOSI = MOSI, const uint8_t pinMISO = MISO, const uint8_t pinCLK
MCP3x6x(const uint8_t pinIRQ, const uint8_t pinMCLK, const uint8_t pinCS = SS, SPIClass *theSPI = &SPI,
const uint8_t pinMOSI = MOSI, const uint8_t pinMISO = MISO, const uint8_t pinCLK = SCK)
```
So scan mode requieres two additional pins, pinIQR for the conversion interrupt flag and pinMCLK (which is not implemented at all).

Both constructors fall back to default definitions which are common in the Arduino world. So if nothing else is explicit specified the default SPI pinout will be used. But to run in Scan Mode it is mandatory to give one interruptcapable pin as well as one PWM pin (altough MCLK functions are not implemented).
Both constructors fall back to default definitions which are common in the Arduino world. So if no pins is explicit specified the default SPI pinout will be used. Therefor it boils down to something simple as `MCP3561 mcp(2, 3, 10);` or even `MCP3561 mcp(10);`.

For initialization of the ADC you must run once:
```
if (!mcp.begin()) {
// failed to initialize
while (1)
;
}
```
After that you could simple do ```int32_t adcdata0 = mcp.analogRead(0);``` to get a value of the single ended channel0.
Please take a look at the examples how to configure these different modes.

An initialization like this:
```
if (!mcp.begin(2)) {
// failed to initialize
while (1)
;
}
attachInterrupt(digitalPinToInterrupt(8), mcp_handler, FALLING);
```
will enable reading differential channel0, in that case ```int32_t adcdata0 = mcp.analogRead(8);``` will give the result.
This also requires an interupt handler ```void mcp_wrapper() { mcp.IRQ_handler(); }```.
Further documentation is available [here](http://nerdyscout.github.io/Arduino_MCP3x6x_Library).

---

***Setting up and reading (differential) channels will change in further version!***
see also:
- https://github.com/fhnw-ise-qcrypt/mcp3564

0 comments on commit 5c25f36

Please sign in to comment.