CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Program will only work in MPLAB simulator

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Richard
Guest







Program will only work in MPLAB simulator
PostPosted: Sun Jun 06, 2004 2:06 pm     Reply with quote

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







PostPosted: Sun Jun 06, 2004 2:08 pm     Reply with quote

PCM 3.185

I am using the MPLAB ICD2 - MPLAB 6.3

NO COMPILER ERRORS!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 06, 2004 2:39 pm     Reply with quote

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
PostPosted: Sun Jun 06, 2004 3:06 pm     Reply with quote

I have been trying to get this working for the past week

You are truely a PCM programmer

Thank you!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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