Loading ...
Sorry, an error occurred while loading the content.

I²C Configuration

Expand Messages
  • marcusmoser81
    Hello, I m interested in programming the ADuC7020 microcontroller. I have succesfully programmed the UART. But now I have problems with I²C. Here is a part of
    Message 1 of 4 , May 9 4:22 AM
    • 0 Attachment
      Hello,

      I'm interested in programming the ADuC7020 microcontroller. I have
      succesfully programmed the UART. But now I have problems with I²C.

      Here is a part of my code:

      void InitI2C(void)
      {
      GP1CON = 0x22; // I2C1 on P1.2 and P1.3,

      I2C1CFG = 0x0002; // Master Enable & Enable Generation of Master
      Clock

      // I2C1-Master setup
      I2C1DIVH = 0xCF; // 0x3232 = 400kHz
      I2C1DIVL = 0xCF; // 0xCFCF = 100kHz

      IRQEN = 0x400; // I2C0 Master Interupt

      // Transmit
      I2C1ADR = 0x1A; // set i2c1 address (LSB = 0, Master Write)=
      Adresse of AD5933

      }



      What isn't right? I don't see a signal on my oscilloscope, but I don't
      find any error in my code. Have I forget some configurations?



      Thanks

      Marcus Moser
    • Jean-Marc ROUXEL
      Hello, I think you forgot the send of data (I2C1MTX register) just after the I2C1ADR. I send you a document from AD on the I2C bus. Jean-Marc ... De :
      Message 2 of 4 , May 10 1:40 AM
      • 0 Attachment

        Hello,

         

        I think you forgot the send of data (I2C1MTX register) just after the I2C1ADR.

         

        I send you a document from AD on the I2C bus.

         

        Jean-Marc

         

         

        -----Message d'origine-----
        De : ADuC_ARM@yahoogroups.com [mailto:ADuC_ARM@yahoogroups.com] De la part de marcusmoser81
        Envoyé : mardi 9 mai 2006 13:23
        À : ADuC_ARM@yahoogroups.com
        Objet : [ADuC_ARM] I²C Configuration

         


        Hello,

        I'm interested in programming the ADuC7020 microcontroller. I have
        succesfully programmed the UART. But now I have problems with I²C.

        Here is a part of my code:

        void InitI2C(void)
        {
          GP1CON = 0x22;     // I2C1 on P1.2 and P1.3,

          I2C1CFG = 0x0002;       // Master Enable & Enable Generation of Master
        Clock

          // I2C1-Master setup
          I2C1DIVH = 0xCF;    // 0x3232 = 400kHz
          I2C1DIVL = 0xCF;    // 0xCFCF = 100kHz

          IRQEN = 0x400;     // I2C0 Master Interupt

          // Transmit
          I2C1ADR =  0x1A;     // set i2c1 address  (LSB = 0, Master Write)=
        Adresse of AD5933

        }



        What isn't right? I don't see a signal on my oscilloscope, but I don't
        find any error in my code. Have I forget some configurations?



        Thanks

        Marcus Moser









      • marcusmoser81
        Hello, I didn t forgot it. For example ( another part of my code ): ... //Transmitregister of Master Channels I2C1MTX = 0x81; //= Control
        Message 3 of 4 , May 17 2:54 AM
        • 0 Attachment
          Hello,
          I didn't forgot it.
          For example ( another part of my code ):
          ...
          //Transmitregister of Master Channels
          I2C1MTX = 0x81; //= Control Register

          warteTX();
          GP4DAT = 0x00000000;

          // AD5933 Reset
          I2C1MTX = 0x10;
          warteTX();

          // Start Frequenz Register = 1 khz = 0x008312,
          I2C1MTX = 0x82; // address: Start
          Frequenz Register
          warteTX();
          I2C1MTX = 0x00; // value:0x00
          warteTX();
          I2C1MTX = 0x83; // address: Start
          Frequenz Register
          warteTX();
          I2C1MTX = 0x83; // value
          warteTX();
          I2C1MTX = 0x84; // address
          warteTX();
          I2C1MTX = 0x12; // value
          warteTX();


          I2C1MTX = 0x88; //address
          warteTX();
          I2C1MTX = 0x00; // value
          warteTX();
          I2C1MTX = 0x89; // address D7 to D0
          warteTX();
          I2C1MTX = 0xC8; // value
          warteTX();

          // Frequenz Sweep Register
          I2C1MTX = 0x85; // address: Frequenz
          Sweep Register
          warteTX();
          I2C1MTX = 0x00; // value:0x00
          warteTX();
          I2C1MTX = 0x86; // address
          warteTX();
          I2C1MTX = 0x41; // value
          warteTX();
          I2C1MTX = 0x87; // address
          warteTX();
          I2C1MTX = 0x89; // value
          warteTX();

          /* AD5933 Standby Modus
          I2C1MTX = 0x80; // address control
          Register
          warteTX();
          I2C1MTX = 0xB0; // Standby Modus
          warteTX();*/


          You see, I send of data, but it doesn't work. Now I have connected
          the pins 1.0 and 1.1 for I2C and have a ADuC7020 as master and a
          ADuC7026 as slave and I have a sigal on the data
          channel, but no signal on clockchannel. I have configurated it like
          this: ( this is a part of the example files from analog)
          #include<ADuC7020.h>

          void delay(int);
          void My_IRQ_Function();

          #define count 0x4; // Number of
          bytes to be recieved - 1
          int i = 0, dat[5]; // Size of
          dat should be (count + 1)


          int main()
          {

          GP1CON = 0x22; // I2C on
          P1.0 and P1.1

          I2C0CFG = 0x82; // Master
          Enable & Enable Generation of Master Clock

          // I2C-Master setup
          I2C0DIV = 0xCFCF; // 0x3232 =
          400kHz

          // 0xCFCF = 100kHz

          IRQ = My_IRQ_Function; // Specify Interrupt
          Service Routine
          IRQEN = 0x400; // I2C0
          Master Interupt


          You can see it. I have configurated the register I2C0CFG as 0x82 and
          in the data sheet it is explained as the register to enable Master &
          enable Generation of Master Clock. But I have no signal on my
          oscilloscope.
          Thanks for your document, it helps me a little bit.

          Marcus Moser
        • Jean-Marc ROUXEL
          I2C bus must have pull-ups (10 kohm) on both the clock and data. Don’t you forgot them ? Jean-Marc ... De : ADuC_ARM@yahoogroups.com
          Message 4 of 4 , May 17 5:41 AM
          • 0 Attachment

            I2C bus must have pull-ups (10 kohm) on both the clock and data. Don’t you forgot them ?

             

            Jean-Marc

             

             

            -----Message d'origine-----
            De : ADuC_ARM@yahoogroups.com [mailto:ADuC_ARM@yahoogroups.com] De la part de marcusmoser81
            Envoyé : mercredi 17 mai 2006 11:54
            À : ADuC_ARM@yahoogroups.com
            Objet : Re: RE : [ADuC_ARM] I²C Configuration

             

            Hello,
            I didn't forgot it.
            For example ( another part of my code ):
            ...
            //Transmitregister of Master Channels
                        I2C1MTX =   0x81;               //= Control Register
                       
                        warteTX();
                        GP4DAT = 0x00000000;
                       
                        // AD5933 Reset
                        I2C1MTX =       0x10;           
                             warteTX();
                       
                        // Start Frequenz Register = 1 khz = 0x008312,
                        I2C1MTX =       0x82;            // address: Start
            Frequenz Register
                        warteTX();
                        I2C1MTX =       0x00;            // value:0x00
                        warteTX();
                        I2C1MTX =       0x83;            // address: Start
            Frequenz Register
                        warteTX();
                        I2C1MTX =      0x83;            // value
                        warteTX();
                        I2C1MTX =       0x84;            // address
                        warteTX();
                        I2C1MTX =       0x12;            // value
                        warteTX();
                       
                       
                        I2C1MTX =      0x88;            //address
                        warteTX();
                        I2C1MTX =      0x00;            // value     
                        warteTX();
                        I2C1MTX =      0x89;            // address D7 to D0
                        warteTX();
                        I2C1MTX =      0xC8;            // value
                        warteTX();
                       
                        // Frequenz Sweep Register
                        I2C1MTX =       0x85;            // address: Frequenz
            Sweep Register
                        warteTX();
                        I2C1MTX =       0x00;            // value:0x00
                        warteTX();
                        I2C1MTX =       0x86;            // address
                        warteTX();
                        I2C1MTX =      0x41;            // value
                        warteTX();
                        I2C1MTX =       0x87;            // address
                        warteTX();
                        I2C1MTX =       0x89;            // value
                        warteTX();
                       
                        /* AD5933 Standby Modus
                        I2C1MTX =       0x80;            // address control
            Register
                        warteTX();
                        I2C1MTX =       0xB0;            // Standby Modus
                        warteTX();*/


            You see, I send of data, but it doesn't work. Now I have connected
            the pins 1.0 and 1.1 for I2C and have a ADuC7020 as master and a
            ADuC7026 as slave and I have a sigal on the data
            channel, but no signal on clockchannel. I have configurated it like
            this: ( this is a part of the example files from analog)
            #include<ADuC7020.h>                          

            void delay(int);
            void My_IRQ_Function();

            #define count 0x4;                              // Number of
            bytes to be recieved - 1
            int i = 0, dat[5];                              // Size of
            dat should be (count + 1)


            int main()
            {
                 
                  GP1CON = 0x22;                              // I2C on
            P1.0 and P1.1

                  I2C0CFG = 0x82;                                // Master
            Enable & Enable Generation of Master Clock
                 
                  // I2C-Master setup
                  I2C0DIV = 0xCFCF;                        // 0x3232 =
            400kHz
                                                           
                  // 0xCFCF = 100kHz     

                  IRQ = My_IRQ_Function;                  // Specify Interrupt
            Service Routine
                  IRQEN = 0x400;                              // I2C0
            Master Interupt


            You can see it. I have configurated the register I2C0CFG as 0x82 and
            in the data sheet it is explained as the register to enable Master &
            enable Generation of Master Clock. But I have no signal on my
            oscilloscope.
            Thanks for your document, it helps me a little bit.

            Marcus Moser










          Your message has been successfully submitted and would be delivered to recipients shortly.