Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Initializing ad7302 with pic18f97j60 (in MikroC)

Status
Not open for further replies.

Bluestar88

Member level 3
Joined
Oct 17, 2014
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
447
I am using PIC 18 series(pic18f97j60) micro controller in my project. I am interfacing this microcontroller with DAC-ad7302. I used PORTF for D7-0 and PORTG For WR, A/B, CS, PD, CLR and LDAC.

I Wrote below code

Code:
void main() {  
     TRISF = 0 ;             // set PORTF as output
        

        TRISG = 0 ;             // set PORTG as output           

  while(1)
                  {

                  PORTG.RG3=1;
                   PORTG.RG4=0;
                   PORTG.RG0=0;
                  // PORTF=UART1_Read();
                  PORTF=0xff;
                   PORTG.RG0=1;
                   PORTG.RG7=0;
}
}
, But I dont have any output in pin 18 of ad7302. It is zero all of the time.:shock: wwwww.png


Please help me.
 

Hi,

I didn´t go deeply through your code.

Please divide into
* initialisation (before the "while")
* communication (within the "while loop")
(usually within the "while loop" ...every pin that is SET ... wil become CLEARED and vice versa.
but in your code RG3 is SET but never CLEARED.. and the next loop run it is a gain SET...
with other pins it´s the same.)

I recommend that your code stricly follows the diagram in the datssheet.

Some additonal hints:
* define useful signal names instead of the "PORTG.RG3" (No one knows what "RG3" is .. without a schematic.)
* RG5 and RG6 are never initialized.

Klaus
 

you don't have any "wait" instruction in your loop

Code:
while(1)
                  {

                  PORTG.RG3=1;
                   PORTG.RG4=0;
                   PORTG.RG0=0;
                  // PORTF=UART1_Read();
                  PORTF=0xff;
                   PORTG.RG0=1;
                   PORTG.RG7=0;
}

and you're doing:

PORTG.RG0=0;
and later:

PORTG.RG0=1;
which is executed very, very fast.
Is this intented?



Also, don't you need to disable comparators and analogue pins for this pic?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top