Giter VIP home page Giter VIP logo

Comments (8)

RobTillaart avatar RobTillaart commented on June 12, 2024

Hi Joel (?),
Will try to have a look this evening, otherwise tomorrow.

I am from Netherlands, which time zone are you in?
(Helps with my planning)

from mcp23s17.

joellecam avatar joellecam commented on June 12, 2024

Hi Rob,

I am French in Normandy. using a chip select decoder is required in many design.

from mcp23s17.

RobTillaart avatar RobTillaart commented on June 12, 2024

Some observations and notes

  • updated code tags in your 1st post for readability
  • had a look at your library, think I understand the purpose from the code.
    You want to give a number between 0..8 and depending on the number it sets the bits.
  • note that set_cs_low(7) is same as calling set_cs_high(uint8_t out)
    Is this on purpose?
  • set_cs_high(uint8_t out) out parameter is not used.
  • datasheet https://assets.nexperia.com/documents/data-sheet/74HC_HCT138.pdf
    This chip you want to control.

Another observation is that you need to learn some bit math AND OR XOR etc.
This set_cs_high(uint8_t out) function would do the same.

void decode3to8::set_cs_low(uint8_t out)
{
  if out > 7 return;
  ::digitalWrite(In2, out & 0x04); 
  ::digitalWrite(In1, out & 0x02); 
  ::digitalWrite(In0, out & 0x01);
}

In your .h file you use

#ifndef _74HC138_H_
#define _74HC138_H_

It is enough to place on the first line

#pragma once

from mcp23s17.

RobTillaart avatar RobTillaart commented on June 12, 2024

I try to modify the MCP23S17 with the addition of a chip selector between MCU and MCP23S17.

What are you trying to accomplish, in more detail?

  • do you want to use 7 x MCP23S17 and select one with your library?
  • something else?

from mcp23s17.

RobTillaart avatar RobTillaart commented on June 12, 2024

@joellecam
had a second look at the error message in your original question.

I modify the MCP23S17.cpp by this

MCP23S17::MCP23S17(uint8_t select, uint8_t address,__DECODE1ON8__ * decode3to8 = &dec3t8 , __SPI_CLASS__ * spi = &SPI )
{
  _address = (address << 1);
  _select  = select;
  _error   = MCP23S17_OK;
  _mySPI   = spi;
  _hwSPI   = true;
  _mydec3to8 = decode3to8 ;
}

should be

MCP23S17::MCP23S17(uint8_t select, uint8_t address,__DECODE1ON8__ * decode3to8, __SPI_CLASS__ * spi )
{
  _address = (address << 1);
  _select  = select;
  _error   = MCP23S17_OK;
  _mySPI   = spi;
  _hwSPI   = true;
  _mydec3to8 = decode3to8 ;
}

The default parameters should only be given in the .h file

from mcp23s17.

joellecam avatar joellecam commented on June 12, 2024

Hi Rob,

Thanks you very much. I have no error. I try the code in the next month after I receive the PCB

Best regards
Joël

from mcp23s17.

RobTillaart avatar RobTillaart commented on June 12, 2024

OK, I close the issue.
FYI, inspired by your library I decided to write my own and one for the 74HC154 too (4 to 16)

https://assets.nexperia.com/documents/data-sheet/74HC_HCT154.pdf

from mcp23s17.

RobTillaart avatar RobTillaart commented on June 12, 2024

@joellecam

just published the two libraries

There is also a 1 to 2 multiplexer in this range but that is left for the future.
If you have time, please give them (or the 138 only) a try.

Again thanks for the inspiration.

from mcp23s17.

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.