• AVR Freaks

Hot!PIC32MM I2C problem, example

Author
Snake
Super Member
  • Total Posts : 190
  • Reward points : 0
  • Joined: 2008/06/08 13:25:18
  • Location: Germany
  • Status: offline
2020/03/27 18:24:32 (permalink)
0

PIC32MM I2C problem, example

Hi,
 
I am trying to use the hardware I2C of the PIC32MM0256GPM028. However I couldn't make it work and I think the PIC32MM documentation is the worst I have ever seen. 
 
If I understood correctly there is not much you have to do to make it work. It should be a master:

#pragma config ALTI2C = OFF             // Alternate I2C1 Pins Location Enable bit (Primary I2C1 pins are used)
 
void main(void)
{

    I2C1BRG = 0x070; // speed, around 100kHz @ 24Mhz
    I2C1CONbits.ON = 0b1; // enable
    
    I2C1CONbits.SEN = 0b1; // start
    
    while (!(I2C1STATbits.S == 1 && I2C1CONbits.SEN == 0)) {}
    
    I2C1TRN = 0b01110100; // send data
    
    while(1) {}

}

 
If I do this I can see the data on the SDA pin. However with approximately 1Hz, yes a single Hz. Changing the BRG register doesn't change anything. Also I cannot see the clock signal on the SCL pin. I suppose something is wrong. Can anyone help? Is there an example that is actually made for this device?
 
Datasheet says that this is driven by the peripheral clock, which is exactly the same as the system clock? Device runs @ 24Mhz and everything else works as expected.
#1

2 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27115
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC32MM I2C problem, example 2020/03/27 23:40:06 (permalink)
    0
    You didn't show all your config settings.
    SDA and SCL are shared with JTAG pins. Have you disabled JTAG?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    Snake
    Super Member
    • Total Posts : 190
    • Reward points : 0
    • Joined: 2008/06/08 13:25:18
    • Location: Germany
    • Status: offline
    Re: PIC32MM I2C problem, example 2020/03/28 04:24:36 (permalink)
    0
    Hi,
     
    thanks, but yes, its off.
     
    #pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)

    #3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5