This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ32002: How to Write SFR Register

Part Number: BQ32002

I want to use BQ32002 to generate a square wave of 1Hz. After setting the FT flag, there will be no reaction when writing the SFR register. Whether the register of 0x22 needs a special method to set is as follows

switch (STATE)

  {
  case BQ32002_EN_IRQ_1Hz:                               
    Driver_IIC_WriteReg(BQ32002_ADDRESS, 0x07, 0b11000000);
    Driver_IIC_WriteReg(BQ32002_ADDRESS, 0x22, 0x01);      
    break;
  case BQ32002_EN_IRQ_512Hz:                            
    Driver_IIC_WriteReg(BQ32002_ADDRESS, 0x07, 0b11000000)
    Driver_IIC_WriteReg(BQ32002_ADDRESS, 0x22, 0x00);      
    break;
  case BQ32002_EN_IRQ_HIGH:                              
    Driver_IIC_WriteReg(BQ32002_ADDRESS, 0x07, 0b10000000);
    break;
  case BQ32002_EN_IRQ_LOW:                               
    Driver_IIC_WriteReg(BQ32002_ADDRESS, 0x07, 0b00000000);
    break;
  default:
    break;
  }

  • It seems you must write to registers 0x20 and 0x21 (SF KEY 1 and SF KEY 2) before accessing SFR.

    The SF KEYS are 0x5E and 0xC7. See tables 14 and 15 for more info:

    "The SF KEY 1 and SF KEY 2 registers are used to enable access to the main special function register (SFR). Access to SFR is granted only after the special function keys are written sequentially to SF KEY 1 and SF KEY 2. Each write to the SFR must be preceded by writing the SF keys to the SF key registers, in order, SF KEY 1 then SF KEY 2."

    I hope this helps

    Kind regards,
    Lane

  • Thank you for your help. I have solved the problem.