RTC with ADC problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

sir,

   

I am tring to add RTC module along with an ADC.  I am counting and displaying  only seconds up to 60 on the furst row of the LCD. I omitted to dispaly the minute,hour,day and other details.The thing works fine with debugger. But after programming the chip the RTC only works, adc is not working. whats my mistake?.I copied the codes used in the example projects.

   

 ***************************

   

main.c

   

****************************

   

   

#include

       

   

<device.h>

   

#include

        "utils.h"   

#include

    <stdio.h>   

void

{

 

 

 

RTC_TIME_DATE Start;

 

    main()    uint8    tmpVar = 0u;    uint16    output;    char    OutputString[12];    /* Fill struct with date and time */   

Start.Sec = 0u;

Start.Min = 0u;

Start.Hour = 0u;

Start.DayOfMonth = 1u;

Start.Month = 1u;

Start.Year = 2007u;

 

    /* Enable all interrupts */   

CyGlobalIntEnable;

 

    /* Set date and time */   

RTC_WriteTime(&Start);

 

    /* Set alarm date and time */   

RTC_WriteAlarmSecond(10u);

RTC_WriteAlarmMinute(0u);

RTC_WriteAlarmHour(0u);

RTC_WriteAlarmDayOfMonth(1u);

RTC_WriteAlarmMonth(1u);

RTC_WriteAlarmYear(2007u);

 

    /* Set alarm mask */   

RTC_WriteAlarmMask(RTC_ALARM_SEC_MASK | RTC_ALARM_MIN_MASK |

RTC_ALARM_HOUR_MASK | RTC_ALARM_DAYOFMONTH_MASK |

RTC_ALARM_MONTH_MASK | RTC_ALARM_YEAR_MASK);

 

    /* Set interval mask - handling of interrupt stubs of the RTC component */   

RTC_WriteIntervalMask(RTC_INTERVAL_SEC_MASK | RTC_INTERVAL_MIN_MASK |

RTC_INTERVAL_HOUR_MASK | RTC_INTERVAL_DAY_MASK |

RTC_INTERVAL_WEEK_MASK | RTC_INTERVAL_MONTH_MASK |

RTC_INTERVAL_YEAR_MASK);

 

ADC_DelSig_1_Start();

ADC_DelSig_1_StartConvert();

 

    /* Start RTC */   

RTC_Start();

 

    /* Start LCD */   

LCD_Start();

 

    /* Prepare 0th column */   

LCD_Position(0u, 0u);

LCD_PrintString(

 

    "RTC : : "    );    /* Print current time */   

tmpVar = RTC_ReadSecond();

PrintDecNumber(tmpVar, 0u, 11u);

tmpVar = RTC_ReadMinute();

PrintDecNumber(tmpVar, 0u, 8u);

tmpVar = RTC_ReadHour();

PrintDecNumber(tmpVar, 0u, 5u);

 

 

{

 

    while    (1u)    /* Make a 100 ms delay */   

CyDelay(100);

 

 

    #if    (CY_PSOC3)    /* Prepare clock tree configuration for low power mode entry */   

CyPmSaveClocks();

 

* Disable RTC interrupt before entering Sleep mode. The device will

* wake up on one pulse-per-second event, but the ISR will be

* executed when RTC interrupts will be enabled, after the clocks

* configuration will be restores. Potentially, this will allow to

* execute RTC ISR quicker, as CyPmSaveClocks() function could

* decrease master clock frequency.

*******************************************************************/

    /*******************************************************************   

RTC_DisableInt();

 

    /* Entry Sleep low power mode */   

CyPmSleep(PM_SLEEP_TIME_NONE, PM_SLEEP_SRC_ONE_PPS);

 

    /* Restore clock tree configuration */   

CyPmRestoreClocks();

 

* Enable RTC interrupt for ISR to be executed on restored clock

* frequency.

*******************************************************************/

    /*******************************************************************   

LCD_Position(1, 0);

LCD_PrintString(

output = ADC_DelSig_1_GetResult16();

sprintf(OutputString,

LCD_Position(1, 0);

LCD_PrintString(OutputString);

LCD_Position(1, 8);

LCD_PrintInt16(output);

RTC_EnableInt();

 

    " "    );    "%u"    , output);     #endif        /* (CY_PSOC3) */   

}

}

*********************************

RTC_int.c

**********************************

 

 

void

{

 

RTC_EverySecondHandler(void)/* Place your every second handler code here. */

 

/* `#START EVERY_SECOND_HANDLER_CODE` */

 

 

/* Get and print current seconds */

temp = RTC_ReadSecond();

PrintDecNumber(temp, 0u, 11u);

 

 

/* Get status */

temp = RTC_ReadStatus();

 

 

/* Get and print active alarm status */

 

{

RTC_Stop();

 

Start.Sec = 0u;

Start.Min = 0u;

Start.Hour = 0u;

Start.DayOfMonth = 1u;

Start.Month = 1u;

Start.Year = 2007u;

 

RTC_WriteTime(&Start);

 

RTC_WriteAlarmSecond(0u);

RTC_WriteAlarmMinute(1u);

RTC_WriteAlarmHour(0u);

RTC_WriteAlarmDayOfMonth(1u);

RTC_WriteAlarmMonth(1u);

RTC_WriteAlarmYear(2007u);

RTC_Start();

temp = RTC_ReadMinute();

PrintDecNumber(temp, 0u, 8u);

LCD_Position(1u, 15u);

LCD_PutChar(

}

 

if (RTC_STATUS_AA & temp) 'A');else

{

LCD_Position(1u, 15u);

LCD_PutChar(

}

 

 

' ');/* `#END` */

}

 

/*******************************************************************************

* Function Name: RTC_EveryMinuteHandler

********************************************************************************

*

* Summary:

* This function is called every minute.

*

* Parameters:

* None.

*

* Return:

* None.

*

*******************************************************************************/

void

{

 

RTC_EveryMinuteHandler(void)/* Place your every minute handler code here. */

 

/* `#START EVERY_MINUTE_HANDLER_CODE` */

 

 

/* Get and print current minutes */

temp = RTC_ReadMinute();

PrintDecNumber(temp, 0u, 8u);

 

 

/* `#END` */

}

0 Likes
3 Replies