18F26J50 F-8MHz(внутр.), для RTCC F-32.768kHz(внешн.кварц)
микроС 5.61
Протеус 7.10
----------
Протеус не выдаёт ошибок,но часы не запускаются,на ножке RTCC нет импульсов.Думаю ошибка в инициализации. вот код.
Код:
#include "RTC.h"
#include "LCDv1.h"
#include "PCF8574.h"
/**************************************************************************************************
*************************************************************************************************/
void PrintHandler(char c);
void InitReload(){
PCF8574_Init();
LCD_init();
LCD_BackLight(1);
PORTB=1;
ANCON0 = 0b11111111; //Config all analog to digital
ANCON1 = 0b00011111; //Config all analog to digital
SSP1CON1.B5=1; //Set MSSP1 enable bit
SSP1CON1.B3 =1; //--------\
SSP1CON1.B2 =0; // \__ //I2C Master mode,SSPM<0:3>- 1000
SSP1CON1.B1 =0; // /
SSP1CON1.B0 =0; //--------/
T1CON = 0b10001101; // Timer 1 initialization
OSCCON = 0b01111100;
///////// Disable all interrupts/////////////////////////////////////////////////////////////////////
INTCON = 0;
INTCON2 = 0XF5;
INTCON3 = 0XC0;
RCON.IPEN = 0;
PIE1 = 0;
PIE2 = 0;
PIR1 = 0;
PIR2 = 0;
/////////////////////////////////////////////////////////////////////////////////////////////////////
EECON2 = 0x55;
EECON2 = 0xAA;
RTCCFG.RTCWREN=1; //Enable writing to RTCEN bit
RTCCFG.RTCEN = 1; //RTCC enabled
PADCFG1.RTSECSEL1 = 1; //-bit1--/RTCC source clock is selected for the RTCC pin
PADCFG1.RTSECSEL0 = 0; //-bit0-/RTCC source clock is selected for the RTCC pin
RTCCFG = 0b00100011; // set pointer to Year
RTCVALL = 0b00010000; // set Year to 2010
RTCCFG = 0b00100010; // set pointer to Month & Day
RTCVALL = 0b00010010; // set Day to the 12rd
RTCVALH = 0b00000101; // set Month to may (decrements pointer to Weekday & Hours)
RTCVALL = 0b00010110; // set Hour to 4
RTCVALH = 0b00000100; // 0=Sun, 6=Sat. set Weekday (decrements pointer to Minutes & Seconds)
RTCVALL = 0; // set Seconds to 0
RTCVALH = 0b00110001; // set Minutes to 33
RTCCFG.RTCWREN=1; //Enable writing to RTCEN bit
RTCCFG.RTCEN = 1; // RTCC enabled
Delay_ms(800);
}
void main() {
InitReload();
//LOOP
while (1) {
RTCCFG = 3; // set pointer to Year
TIME.year = RTCVALL; // read Year
RTCCFG = 2; // set pointer to Month & Day
TIME.day = RTCVALL; // read Day
TIME.month = RTCVALH; // read Month & decrement pointer
TIME.hours = RTCVALL; // read Hours
TIME.weekday = RTCVALH; // read Weekday & decrement pointer
TIME.seconds = RTCVALL; // read Seconds
TIME.minutes = RTCVALH; // read Minutes (pointer already at 0)
//=============
hours = (((TIME.hours & 0x30) >> 4) * 10) + (TIME.hours & 0x0F);
minutes = (((TIME.minutes & 0x70) >> 4) * 10) + (TIME.minutes & 0x0F);
seconds = (((TIME.seconds & 0x70) >> 4) * 10) + (TIME.seconds & 0x0F);
year = (((TIME.year & 0xF0) >> 4) * 10) + (TIME.year & 0x0F);
month = (((TIME.month & 0x10) >> 4) * 10) + (TIME.month & 0x0F);
day = (((TIME.day & 0x30) >> 4) * 10) + (TIME.day & 0x0F);
//=========
LCD_SetPosition(0,0);
LCD_PrintString("EfimiusI2CTEST");
LCD_SetPosition(1,0);
LCD_PrintValue_uChar(seconds);
delay_ms(500);
//End of LOOP
//=========
}
}
Буду рад любой посильной помощи или совету.