Markdem
Joined: 24 Jun 2005 Posts: 206
|
ADE7753 reading problems |
Posted: Fri Mar 21, 2008 11:23 pm |
|
|
Hello, I am tring to read some data out of a ADE7753 chip, but am having some issues. I Built a Proteus model so I can use the logic analyser, as i dont have a real one handy. I have made the PIC send out what the ADE7753 is expecting, including the CS and CLK lines. I have also simulated a ADE7753 response, and it all looks good. However, when I try this in real hardware, it still does not work. The responce from the ADE is always 255. I am tring to read the die revision number, so i dont think this is right.
The following is the code that I am tring to use
Code: |
#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN,NOBROWNOUT,NOMCLR
#use delay(clock=48000000)
#define AD7758_CS PIN_A0
#define ADE_DOUT PIN_C7
#define ADE_DIN PIN_B0
#define ADE_CLK PIN_B1
#include "LCD420.c"
int test = 0, i, count;
int ADE_OUT_DATA = 63; //chip version register from datasheet
void main()
{
lcd_init();
printf(lcd_putc,"Ready");
output_high(AD7758_CS);
delay_ms(1000);
while(1)
{
ADE_OUT_DATA = 63;
output_low(AD7758_CS);
delay_us(1);
for(i=1;i<=8;++i)
{
output_high(ADE_CLK);
// delay_us(1);
output_bit(ADE_DOUT, shift_left(&ADE_OUT_DATA,1,0));
// delay_us(1);
output_low(ADE_CLK);
// delay_us(1);
}
output_low(ADE_DOUT);
delay_us(4);
for(i=1;i<=8;++i)
{
output_high(ADE_CLK);
// delay_us(1);
shift_left(&test,1,input(ADE_DIN));
output_low(ADE_CLK);
// delay_us(1);
}
output_high(AD7758_CS);
lcd_gotoxy(1,1); //data returned from ADE7753
printf(lcd_putc,"Data = %U",test);
lcd_gotoxy(1,2); //Counter to show PIC is working
printf(lcd_putc,"%U",count);
delay_ms(500);
count++;
}
}
|
I think this is going to be a timing issue. I have checked that data sheet for timing info, but from what I can see in Proteus, the timing is a lot slower then the minimums. For example, the minimum between the rise and the fall of the clock should be 50ns, but mine is 800ns.
Should this be a problem?
Also, the write to the ADE7533 is high to low clock, and the read is low to high. If i wanted to use the SPI hardware, how would I set it up? I know there is a SPI_XMIT_L_TO_H, but i need a SPI_RCV_L_TO_H. Is there any way to use the hardware SPI with this chip?
Thanks,
Mark |
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Fri Mar 21, 2008 11:49 pm |
|
|
One other thing I have just noticed, If I remove the ADE7753, is still get 255 as the return. I dont have to pull the SPI Lines down, do I?
Thanks again,
Mark |
|