0

I am using PIC32MX795f512L and integrating time-based features using MCP79410 RTC. Due to some application purpose, I am using an external RTC (MCP79410).

I just want to use two alarm interrupts, but I can access only one alarm interrupt. If I enabled ALM0 and ALM1, only the last alarm which I used is working. Another alarm interrupt is not working.

Code I have tried:

void RTCInit(void){
    I2CConfigure(I2C2, I2C_ENABLE_SLAVE_CLOCK_STRETCHING);  
    I2CSetFrequency(I2C2,SYSTEM_CLK,RTC_CLK);
    I2CSetSlaveAddress(I2C2,RTC_WRITE_ADDR,0,I2C_USE_7BIT_ADDRESS);
    I2CEnable(I2C2,TRUE);
}


void ConfigI2C(void){
    PORTSetPinsDigitalIn(IOPORT_E, BIT_9);
    INTCONSET = 0x00000002;
    INTSetVectorPriority(INT_EXTERNAL_2_VECTOR, INT_PRIORITY_LEVEL_3);
    INTSetVectorSubPriority(INT_EXTERNAL_2_VECTOR, INT_SUB_PRIORITY_LEVEL_1);
    INTEnable(INT_INT2, INT_ENABLED);
}  

Alarm I tried:

void SetALMTime(void)
{
    int temp;
    WriteAddress[0] = RTC_WRITE_ADDR;
    DelayMs(2);
    WriteOnI2C(ADDR_ALM0MIN,0x01); //min to be alarmed ALM0
    DelayMs(2);
    WriteOnI2C(ADDR_ALM0CTL,0x10); // alarm0 compare min
    DelayMs(2);
    WriteOnI2C(ADDR_ALM1MIN,0x00); //min to be alarmed ALM1
    DelayMs(2);
    WriteOnI2C(ADDR_ALM1CTL,0x10);  // alarm1 compare min
    DelayMs(2);
    WriteOnI2C(ADDR_CTRL,0x30);
    DelayMs(2);
}
Lundin
  • 195,001
  • 40
  • 254
  • 396
Shiva
  • 531
  • 4
  • 6
  • 14

1 Answers1

0

In your RTCInit function make sure to enable bits 5 and 4 of the control register (0x07). Those two bits are required to enable both alarms. None of the macros listed within that function seem to say something about enabling the two alarms. For reference use the MCP79410 datasheet section 4.1.1 RTCC REGISTER ADDRESSES.

This is the link for the datasheet: MCP7941X datasheet

Regards.

  • ya,to activate both alarm, i have to activate the bit 5 and 4. first i tried that only.any other configuration has to be done? – Shiva Apr 03 '14 at 10:59