I had the problem with the RTC on the MCB2300 board, and of course ask google. But I studied about 3 hours and found 50 problems with the RTC, LPC processor, and some solutions that seem to me fairly hooked. Someone solve the problem by changing the capacity of 22pF to 15 pF or vice versa. Someone threw a magic to the processor, someone claimed that the ARM broken. But it passed almost the whole day and my board simply is not working on the external crystal 32 768. But if I switch to the internal clock RTC is working perfectly. Someone even claimed that the oscilloscope can capture RTC oscillations, because of the RTC sensitivity.
My problem was that the oscilloscope see how the X1 line at 400mV and does not oscillate, while the X2 line to 0V. But if you put your finger on the oscillator appears a PWM signal duty cycle 30% at a frequency of some 50 Hz, which sounds a bit illogical. I had a similar problem on PIC24FJ256GB110 processor in which there is a hardware error of the processor that is not written in any documentation. Specifically PIC24FJ256GB110 will not start to oscillate if the X2 line RTC oscillator is not retreat with 2 Mohm resistance to Vcc. Original development board has this strange and confusing illogical resistor.
I tried the ARM board "RTC X2 line" pull with the same resistance but it still did not work. Tried all the examples from the net, each of them thoroughly studied. Thoroughly checked and passed a datasheet for the RTC. But still does not work. All configuration examples on the net come down to it:
Turn the power!!! Select the oscillator!!!
But I developed a project with LPC2378 and remembered how I put the crystal on that board. When I tried it on this board, magic, RTC is working perfectly. On the oscilloscope I have a clean 32.768 on the lines X1 and X2. The amplitude is about 2V.
My original Keil board is delivered with a defective "China" crystal.
When I replaced the crystal, everything started to work perfectly on LPC2368 MCB2300. Of course, but it was gone all day...
Here's my function RTC that we work perfectly on LPC2368 and LPC2378 processor, of course, after I replaced the crystal on the MCB2300.
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Header file <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #ifndef SERVICE_H_ #define SERVICE_H_ typedef struct{ unsigned char seconds; unsigned char minutes; unsigned char hours; unsigned char day_of_week; unsigned char day_of_month; unsigned char month; unsigned short int year; unsigned short int day_of_year; }RTC_T; extern volatile unsigned char rtc_update; RTC_T Read_RTC(void); void Write_RTC(RTC_T* new_rtc); #endif //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Source file<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #include <RTL.h> #include <stdio.h> #include <LPC23xx.H> /* LPC23xx definitions */ #include "rtc.h" volatile unsigned char rtc_update; /*****************************************************************************************/ void Write_RTC(RTC_T* new_rtc){ RTC_CCR &= ~0x01; /* disable RTC */ RTC_SEC = new_rtc->seconds; RTC_MIN = new_rtc->minutes; RTC_HOUR = new_rtc->hours; RTC_DOW = new_rtc->day_of_week; RTC_DOM = new_rtc->day_of_month; RTC_MONTH = new_rtc->month; RTC_YEAR = new_rtc->year; RTC_DOY = new_rtc->day_of_year; RTC_CCR |= 0x01; /* enable RTC */ } /*****************************************************************************************/ RTC_T Read_RTC(void){ RTC_T rtc; rtc.seconds = ((RTC_CTIME0 & 0x0000003F)>> 0); rtc.minutes = ((RTC_CTIME0 & 0x00003F00)>> 8); rtc.hours = ((RTC_CTIME0 & 0x001F0000)>> 16); rtc.day_of_week = ((RTC_CTIME0 & 0x07000000)>> 24); rtc.day_of_month = ((RTC_CTIME1 & 0x0000001F)>> 0); rtc.month = ((RTC_CTIME1 & 0x0000FF00)>> 8); rtc.year = ((RTC_CTIME1 & 0x0FFF0000)>> 16); rtc.day_of_year = ((RTC_CTIME2 & 0x00000FFF)>> 0); RTC_CCR |= 0x01; return (rtc); } /*****************************************************************************************/ void isr_rtc_event(void) __irq { /* one secound RTC interrupt heandler*/ if (RTC_ILR &=0x00000001){ RTC_ILR = 0x00000001; rtc_update = 1; } VICVectAddr = 0; /* Acknowledge Interrupt */ } /*****************************************************************************************/ void RtcInit(){ PCONP |= 0x200; /* Enable power for RTC */ RTC_CCR = 0x12; /* CTC reset and select RTC clock from 32 Khz.oscillator */ RTC_ILR = 0xFF; /* Clear RTC interrupt register */ RTC_AMR = 0xFF; /* Dasable all the alrams. */ RTC_CISS = 0; /* Disable all subsecond interrupts. */ RTC_CCR = 0x11; /* Enable RTC */ RTC_CIIR = 0x01; /* Enable only second count interrupt. minute */ VICVectAddr13 = (U32)isr_rtc_event; /* Set Interrupt Vector */ VICVectCntl13 = 13; /* use it for RTC Interrupt */ VICIntEnable = (1 << 13); /* Enable Interrupt */ } /*****************************************************************************************/
It would be good if Keil could improve the factory testing of their products.
Their designs are normally good - much better than a number of competitors - but the production quality is not the best.
I have received one board with a pin in the air.
One board where two serial connectors were twisted 45 degrees but not a mark on the plastic bag, so it looks like someone had stood on the board before placing it in the plastic bag.
And I haven't done full inspections of the boards - just used them for specific tests that are better done on hardware than in the simulator while waiting for our own hardware.