EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Hardware before SPI interfacing

Started by sani_figs June 21, 2008
Hi, I will connect my ADE7758(metering IC) to a Z8 Encore! MCU through SPI
(4pins: SCK,MISO,MOSI,CS). My problem is, although the input and output
voltage ratings of the two chips match(5-6Volts input and output), I feel
that there should be some hardware in between, meaning, I should not
DIRECTLY connect the SPI pins of the MCU to the pins of the other IC. Any
help on this matter will be well appreciated. Thanks!
sani_figs wrote:
> Hi, I will connect my ADE7758(metering IC) to a Z8 Encore! MCU through SPI > (4pins: SCK,MISO,MOSI,CS). My problem is, although the input and output > voltage ratings of the two chips match(5-6Volts input and output), I feel > that there should be some hardware in between, meaning, I should not > DIRECTLY connect the SPI pins of the MCU to the pins of the other IC. Any > help on this matter will be well appreciated. Thanks!
If the SPI pins of each part are electrically compatible (6V ???), they get connected directly. MCU ADE7758 SCLK SCLK CS CS MOSI DIN MISO DOUT All you have to do then is mode the MCU to the correct clock phase and clock polarity for the ADE7758, select it, transfer the correct amount of data, and deselect it. Dave
sani_figs wrote:

> Hi, I will connect my ADE7758(metering IC) to a Z8 Encore! MCU through SPI > (4pins: SCK,MISO,MOSI,CS). My problem is, although the input and output > voltage ratings of the two chips match(5-6Volts input and output), I feel > that there should be some hardware in between, meaning, I should not > DIRECTLY connect the SPI pins of the MCU to the pins of the other IC. Any > help on this matter will be well appreciated. Thanks!
6V looks more like absolute maximum ratings. But you can read the datasheets to see if it works: ADE7758 says for logic inputs it needs at least 2.4V for detecting high and no more than 0.8V for detecting low. It outputs at least 4V for high and max 0.4V for low. The Z8 ENCORE! F0830 has some 5V tolerant pins, low level output voltage is max 0.6V and for low level input voltage it is max 0.3*Vdd allowed. This is 0.99V for 3.3V=Vdd, so this works. But the high level output voltage is min 2.4V, which means for the worst case that it doesn't work. You should add level converters for the 3 outputs from the Z8 to the ADE7758, e.g. SN74LVC1T45 or SN74LVC8T245. -- Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
Hi,
I tried connecting the pins directly and i tested it with a simple code
which fetches a single byte of data. I am getting no response from the
chip. Can this be due to the need of level translator? or maybe because I
made wrong SPI settings? I set my CPOL to 0 and CPHA to 1, but I'm feeling
that my SCLK freq is wrong also because I used the BRH and BRL (for baud
rate) settings that was used in the sample code from zilog (controlling a
DS1722 temp sensor). I can't make out the right settings for these
parameters from the datasheet of the ADE7758. By the way, Im using a
Z8F6421 MCU. 
Thanks!
sani_figs wrote:

> I tried connecting the pins directly and i tested it with a simple code > which fetches a single byte of data. I am getting no response from the > chip. Can this be due to the need of level translator?
No, it should work. You can measure the voltage. The level translator would be needed only for production, because the specification says 2.4V min output, which is the lower limit for detecting it as high level, too, so this is on the border, but I assume usually the output voltage is higher.
> or maybe because I > made wrong SPI settings? I set my CPOL to 0 and CPHA to 1, but I'm feeling > that my SCLK freq is wrong also because I used the BRH and BRL (for baud > rate) settings that was used in the sample code from zilog (controlling a > DS1722 temp sensor). I can't make out the right settings for these > parameters from the datasheet of the ADE7758.
When I'm reading the datasheet for the ADE7758 (http://www.analog.com/UploadedFiles/Data_Sheets/ADE7758.pdf), there are some nice timing diagrams on page 7. Compare this to the timing diagrams of the SPI module. If you have a scope, the easiest way would be to scope clock and data and compare it to the timing diagram of the ADE7758. You can try to implement a bitbanging function instead of using the SPI module of your CPU, to verify the connection and the commands for the ADE7758, then scope it, then compare it with the signals the SPI module generates. BTW: there are other microcontrollers which are working with 5V supply voltage, if you want to save one voltage regulator. -- Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
sani_figs wrote:
> > I tried connecting the pins directly and i tested it with a simple > code which fetches a single byte of data. I am getting no response > from the chip. Can this be due to the need of level translator? or > maybe because I made wrong SPI settings? I set my CPOL to 0 and > CPHA to 1, but I'm feeling that my SCLK freq is wrong also because > I used the BRH and BRL (for baud rate) settings that was used in > the sample code from zilog (controlling a DS1722 temp sensor). I > can't make out the right settings for these parameters from the > datasheet of the ADE7758. By the way, Im using a Z8F6421 MCU.
What, if anything, is this about? If you want to post a followup via groups.google.com, ensure you quote enough for the article to make sense. Google is only an interface to Usenet; it's not Usenet itself. Don't assume your readers can, or ever will, see any previous articles. More details at: <http://cfaj.freeshell.org/google/> -- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section. ** Posted from http://www.teranews.com **
On Sat, 21 Jun 2008 00:59:25 -0500, "sani_figs" <adrian_figui@yahoo.com>
wrote:

>Hi, I will connect my ADE7758(metering IC) to a Z8 Encore! MCU through SPI >(4pins: SCK,MISO,MOSI,CS). My problem is, although the input and output >voltage ratings of the two chips match(5-6Volts input and output), I feel >that there should be some hardware in between, meaning, I should not >DIRECTLY connect the SPI pins of the MCU to the pins of the other IC. Any >help on this matter will be well appreciated. Thanks!
A series resistor on the interconnecting lines will limit the current between two pins if, during startup or initialization, you inadvertently end up with two outputs fighting each other. Generally (I'm sure there are exceptions) for microcontroller I/O pins, a power-on reset passes through a high impedance, off-bus state to a high impedance, input-port state. One typically has to explicitly configure a peripheral (e.g., SPI) to drive output pins, after the remote chip has finished its power-on routine and has settled down to the correct states. However, you can add something like a 1K series resistor to the interconnecting lines as insurance at the cost of slowing down the edges on the transitions and reducing your maximum achievable SPI clock. -- Rich Webb Norfolk, VA
>When I'm reading the datasheet for the ADE7758 >(http://www.analog.com/UploadedFiles/Data_Sheets/ADE7758.pdf), there are >some nice timing diagrams on page 7. Compare this to the timing diagrams
of
>the SPI module.
Thanks Sir Frank, I'll try looking at these timing diagrams since I have noted that when reading data from the chip, there should be a 4us delay (t9 in the timing diagram) between the fetch command and the output of the data. Maybe I'm missing that part in the code. I'll try implementing that delay. :)
Frank Buss ha scritto:
> 6V looks more like absolute maximum ratings. But you can read the > datasheets to see if it works: ADE7758 says for logic inputs it needs at > least 2.4V for detecting high and no more than 0.8V for detecting low. It > outputs at least 4V for high and max 0.4V for low. The Z8 ENCORE! F0830 has > some 5V tolerant pins, low level output voltage is max 0.6V and for low > level input voltage it is max 0.3*Vdd allowed. This is 0.99V for 3.3V=Vdd, > so this works. But the high level output voltage is min 2.4V, which means > for the worst case that it doesn't work...
uhm, Voh min 2.4V @ which current ? and on hiz load ? regards
On Jun 21, 10:27=A0am, "sani_figs" <adrian_fi...@yahoo.com> wrote:
> Hi, > I tried connecting the pins directly and i tested it with a simple code > which fetches a single byte of data. I am getting no response from the > chip. Can this be due to the need of level translator? or maybe because I > made wrong SPI settings? I set my CPOL to 0 and CPHA to 1, but I'm feeling=
> that my SCLK freq is wrong also because I used the BRH and BRL (for baud > rate) settings that was used in the sample code from zilog (controlling a > DS1722 temp sensor). I can't make out the right settings for these > parameters from the datasheet of the ADE7758. By the way, Im using a > Z8F6421 MCU. > Thanks!
Are you pulling the CS low before performe any operation. to check your code, scope the SCLK pin and MOSI pin to see the frequency, polarity and phase. Thanushan

The 2024 Embedded Online Conference