|
|
View previous topic :: View next topic |
Author |
Message |
Richard Guest
|
Program will only work in MPLAB simulator |
Posted: Sun Jun 06, 2004 2:06 pm |
|
|
Dear PCM users,
I have recently bought the PCM compiler, I am having problem with the following code:
Code: |
#if defined(__PCM__)
#include <16F874.h>
#device ICD=TRUE
#fuses XT,NOWDT,NOPROTECT,NOLVP,NOPUT,NOBROWNOUT
#use delay(clock=4000000)
#endif
#include <lcd.c>
int sec=0; //second
int min=0;//minute
int hrs=0; //hour
int milli=0;
int increment = 0;
int flag=0;
int data=0;
void display()
{
if (flag==1)
{
lcd_gotoxy(0,1);
printf(lcd_putc,"%02U:%02U",hrs,min);
}
else
{
lcd_gotoxy(1,1);
printf(lcd_putc,"%S",data);
}
}
#int_rtcc
void clock_isr()
{
increment++;
if (increment==2)
{ milli++;
increment=0;
}
if (milli==10) // 10*100ms = 1second passed
{
sec++;
milli=0;
}
if (sec==60) // 60*1sec = minute
{
sec=0;
min++;
flag=1;
}
if (min==60)
{
min=0;
hrs++;
flag=1;
}
if (hrs==24)
{
sec=0;
hrs=0;
flag=1;
}
if (milli < 10) //milli lower than 10 exit after incrementing milli
set_RTCC(60); //setup TMR0 to count upto 100ms
}
void main()
{
lcd_init();
set_RTCC(60);
setup_counters(RTCC_INTERNAL,RTCC_DIV_256);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
while (1)
{
if (flag==1)
{
display();
flag=0;
}
}
} |
The code is for a rel time clock on the LCD (CCS LCD DRIVERS),
the interrupt happens every 49ms - using timer0
When I use MPLAB sim it works as it should, but if i blow it onto the chip I get nothing on the display.
I have tested the LCD, PIC, connectivity.
Can anyone program my code into a PIC or find any mistakes
I hope someone can help |
|
|
Richard Guest
|
|
Posted: Sun Jun 06, 2004 2:08 pm |
|
|
PCM 3.185
I am using the MPLAB ICD2 - MPLAB 6.3
NO COMPILER ERRORS!!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 06, 2004 2:39 pm |
|
|
I tested it with PCM vs. 3.188. I changed the printf statements
to send output directly to the PC terminal window, because I don't
have a LCD on my demo board.
I also added one line to your int_rtcc function, so that it would
display output every second, instead of every minute.
That's better for a test program.
Then it worked. It displayed this every second:
00:00
if (milli==10) // 10*100ms = 1second passed
{
sec++;
milli=0;
flag = 1; // Add this line to get output every 1 second.
} |
|
|
Richard Guest
|
THANKS |
Posted: Sun Jun 06, 2004 3:06 pm |
|
|
I have been trying to get this working for the past week
You are truely a PCM programmer
Thank you!!! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|