noxus
Joined: 16 Nov 2009 Posts: 6
|
RTC support for PIC18F46J50 |
Posted: Tue Jan 12, 2010 9:28 am |
|
|
Hello all,
I'm using compiler version 4.099 and I'm trying to create an application in which an RTC is going to be used. The external crystal is connected to RC0 and RC1 of the PIC microcontroller.
First of all, it looks like not all the configuration fuses are supported within this version of the compiler. The RTCC Clock Select fuse (RTCOSC) is not listed as a valid fuse.
-> As a workaround I'm manually setting the fuses in MPLAB now
The second problem I'm facing is the #INT_RTC statement. When this statement is placed in my code I get the following error message from the compiler:
Error 7 "main.c" Line 18(0,1): Invalid Pre-Processor directive
I have the same program working with an PIC18F46J11.
Does any of you know how I can make this also work for the PIC18F46J50. It looks like this microcontroller is not properly supported in version 4.099.
Code: |
#include <18F46J50.h>
//#FUSES NOWDT
//#FUSES INTRC_PLL
//#FUSES NOPROTECT
//#FUSES RTCOSC_T1
// Note: Fuses are set manually from within MPLAB since the RTCOSC_T1 fuse is not known by the compiler.
#use delay(clock=8000000)
#int_RTC // The compiler says this is a Invalid Pre-Processor directive
void RTC_isr(void)
{
output_toggle(PIN_E2);
}
void main()
{
time_t tWriteTime;
time_t tAlarmTime;
tWriteTime.tm_year = 10;
tWriteTime.tm_mon = 1;
tWriteTime.tm_mday = 15;
tWriteTime.tm_wday = 2;
tWriteTime.tm_hour = 16;
tWriteTime.tm_min = 0;
tWriteTime.tm_sec = 0;
tAlarmTime.tm_year = 10;
tAlarmTime.tm_mon = 1;
tAlarmTime.tm_mday = 15;
tAlarmTime.tm_wday = 2;
tAlarmTime.tm_hour = 16;
tAlarmTime.tm_min = 0;
tAlarmTime.tm_sec = 1;
setup_rtc(RTC_ENABLE, 0x00);
setup_rtc_alarm(RTC_ALARM_ENABLE,RTC_ALARM_DAY, 0xff); // 0xff repeat
rtc_write(&tWriteTime);
rtc_alarm_write(&tAlarmTime);
// Configure interrupts
enable_interrupts(INT_RTC);
enable_interrupts(GLOBAL); // enable global interrupts
while (1)
{
output_toggle(PIN_E1);
delay_ms(200);
}
}
|
Thanks in advance for the help! |
|