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 CCS Technical Support

Now the RTC doesn't print correctly! (??:??:??)

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



Joined: 26 Jan 2004
Posts: 15
Location: Kiruna, Sweden

View user's profile Send private message

Now the RTC doesn't print correctly! (??:??:??)
PostPosted: Mon Jan 26, 2004 3:52 pm     Reply with quote

[Edit]
the program was compiled using IDE 3.36 and compiler version PCM 3.170
[/Edit]
I have been sweating over this for several days now...

I have CCS PIC development kit and for some reason all I get is garbage.

I have simplified the code 'till nothing is left but a simple printf command. It still doesn't do anything but FLOOD my serial input/output monitor (SIOW).

This is the header file code:
#include <16F877A.h>
#fuses HS, NOLVP, NOWDT, PUT
#use delay(clock=2000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

And this is the main code:
void main()
{
// int hour, min, sec, last_sec;
printf("random text");
delay_ms(1000);

/*rtc_init();
rtc_set_datetime(0,0,0,0,hour,min);
printf("\r\nkljaf");
delay_ms(1000);
while(TRUE)
{
rtc_get_time(hour,min,sec);
if(sec!=last_sec)
{
printf("\r\nhejhopp");
display_bcd(hour); putc(':');
display_bcd(min); putc(':');
display_bcd(sec);
last_sec=sec;
}
if(kbhit() && (getc()=='S'))
set_time();
}*/
}


Now, why on earth does my output look like garbage? The SIOW is configured to listen to the rigth com-port at the correct baud and bit settings..
Oh, and yes, I am sure that I compile the right file and that I program it with the right hex file afterwards.

!!!WHY!!!
Rolling Eyes


Last edited by Sandman on Mon Jan 26, 2004 5:13 pm; edited 1 time in total
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Mon Jan 26, 2004 4:07 pm     Reply with quote

Code:
#include <16F877A.h>
#fuses HS, NOLVP, NOWDT, PUT
#use delay (clock=20000000,RESTART_WDT)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

void main()
{
   while(1) {
      printf("random text");
      delay_ms(1000);
   }
}


Works with my V3.184 compiler. Eventhough you specified NOWDT, I have my suspicions about the init code so I added the "RESTART_WDT" statement to the #use delay line. I need to look more closely at the assembly listing but just haven't had the time.

Also I added the parity and bits statements to your #use rs232 but it does work without those.

And finally, when I clipped out the stuff you posted that was inside comments, you didn't have a while loop around your printf & delay so they would have only executed once and the PIC would hit the SLEEP command inserted by the compiler before the closing bracket of main(). I added a while(1){} around your code just to keep it running.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Sandman



Joined: 26 Jan 2004
Posts: 15
Location: Kiruna, Sweden

View user's profile Send private message

PostPosted: Mon Jan 26, 2004 5:01 pm     Reply with quote

[Edit]
In the code below, if I set the variables to the initial values as follows: hour=10, min=20
I still get 00:00:00 as my first and only "numerical" printout. The following is questionmarks. I also tried with a delay after setting the time, to allow the RTC to increase its timer to 1 or 2 seconds, but it still prints as 00:00:00.

I feel that I have exhausted all tests and trials and I can not for the life of me see why this doesnt work!

Now it doesn't even say 00:00:00 first.. it starts with the questionmarks right off the bat, and I have not even re-programmed the pic, just stopped it and re-set it. aargh Shocked

[/Edit]
Embarassed
Well, it wasn't VERY obvious, but I found out when I looked in SIOW that I had to change the display to ASCII and increase the font-size... I always assumed that it -was- set to ASCII.. So that took care of the printf statement...

Now, I get the text, but when I try to display the time from the RTC, I get 00:00:00 the first time I print it out, and for ALL consequtive printings, I get ??:??:?? though on another computer running the same program but on a PIC16F877 (not 877A) it prints <<:<<:<<....
The code is:

#include <16F877A.h>
#fuses HS, NOLVP, NOWDT, PUT
#use delay (clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)

#include <nju6355.c>

void display_bcd(byte n)
{
putc( (n/16)+'0');
putc( (n%16)+'0');
}

void main()
{
int hour=0, min=0, sec;

rtc_init();
rtc_set_datetime(0,0,0,0,hour,min);
while(TRUE)
{
printf("\r\nkjkep");
rtc_get_time(hour,min,sec);
delay_ms(10);
display_bcd(hour); putc(':');
delay_ms(10);
display_bcd(min); putc(':');
delay_ms(10);
display_bcd(sec);
delay_ms(10);
printf("\r\n");
delay_ms(500);
}
}


I think the nju6355.c is part of the CCS package, so I wont re-print it here unless told otherwise. (It's not that big, but it is created by CCS and should work?)

The code above is a "rip-off" from excercise 19 in the booklet that came with the development code. Even when following the code in the example to the letter, I still dont get the time printed out, just the questionmarks.

Anyone who knows if this is a normal problem?
Dargar



Joined: 12 Dec 2003
Posts: 25

View user's profile Send private message

Try this!
PostPosted: Tue Jan 27, 2004 5:28 am     Reply with quote

Cool

YES! I get to help someone!!

I had the same problem with my RTC, and it turned out that, at least in my copy, the nju6355.c lists B3 as the IO pin to connect to the RTC, but in the leaflet in the drawing, it tells you to connect B4 to the RTC IO..

So, either change the c file to B4 or take the wire that sits in B4 and move it to B3!

Good luck, and let me know if it helped!
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