Jump to content

Panvadee

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Panvadee

  • Rank
    Newbrie
  1. Thanks Alex. I had a programming problem before I thought it might be the LF series problem, but it was just a dodgy cable.
  2. What can I do if I use PIC16LF648a? It doesn't have any of the PIC16LFxxx on the list above.
  3. It doesn't have any of the PIC16LFxxx on the list above. What can I do if I use PIC16LF648a?
  4. We are trying to develop an I2C slave function on a PIC16F876A to communicate with the master device a PIC18F452. The master is successfully talking to other slaves on the bus, but we are struggling to get our own slave working. We have encountered the following conditions: -The slave matches the address from the master and enters the interrupt routine. -However the slave is not sending an ACK on reception of the address. -It is also not clearing the buffer upon reading the address. Therefore SSPBUF is never anything but the address of the slave Initially we had the master waiting for an ACK that was never returned, so instead we tried sending data after the address, which causes an overflow in the slave as you would expect. We are at a loss to understand why reading 'sspbuf'is not clearing the register, and why the automatic acknowledge from the MSSP module is not being sent on an address match? See our attached code: //initial state //Configure port A trisa = 0x35; //Configure port B trisb = 0xBF; //Configure port C trisc = 0xFF; //Configure to OFF A/D pins adcon1 = 0x06; //Initialize port A porta = 0x00; //Initialize port B portb = 0x00; //Initialize port C portc = 0x00; //Enable interrupts (Global,SSP,External) intcon = 0xD0; //Enable Serial Port set_bit(pie1,SSPIE); //Configure for I2C Slave Mode sspcon = 0b00110110; sspcon2 = 0b00000000; sspstat = 0b10000000; dummy= sspbuf; //clear buffer sspadd = 0x10; //Slave Address //Handle I2C interrupt if (pir1.SSPIF == 1) { if (sspstat.R_W == 0) //Slave read data { address = sspbuf; //read address from buffer pir1.SSPIF = 0; //clear interrupt while (!sspstat.BF); //wait for next data loaded HV = sspbuf; //read buffer voltage high byte pir1.SSPIF = 0; //clear interrupt while (!sspstat.BF); //wait for next data loaded HC = sspbuf; //read buffer current high byte pir1.SSPIF = 0; //clear interrupt while (!sspstat.BF); //wait for next data loaded LVC = sspbuf; //read buffer voltage & current low byte } }
×