pic24fv32ka302 I2C clock stretch not working

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,429
Hello all.

I just started messing around some pic24s and ran into a little problem. I am trying to use the I2C in slave mode and so far it will acknowledge the address, but it does not hold the clock line low to peform clock stretching.

Here's what I'm working with now...
Code:
__i2c_slave_init:
  mov #0, w0
  mov.b WREG, i2c_len
  mov.b WREG, i2c_flags
  bset I2C1CON, #I2CSIDL
  bset I2C1CON, #DISSLW
  bset I2C1CON, #STREN
  movlf #0xff, I2C1BRG
  movlf #0x22, I2C1ADD   
  bclr IFS1, #SI2C1IF
  bset I2C1CON, #I2CEN
  return

.end
I am also using the secondary pins (ASDA, ASCL)... I know that shouldn't make a difference, but who knows?
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,429
I decided to give it a whirl as a master and wrote a successul message to another pic. The problem now is it won't even acknowledge the address in slave mode, but it will however acknowledge the general call address (0).

Here's the latest setup...

Code:
__i2c_init:
  mov #0, w0
  mov.b WREG, i2c_len
  mov.b WREG, i2c_flags
  movlf #0x20, I2C1ADD  
  movlf #0xff, I2C1BRG
  movlf #0x22c0, I2C1CON
  bset I2C1CON, #I2CEN
  bclr IFS1, #SI2C1IF 
  return
 
Last edited:
Top