![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) | |
|
Quote:
What about the x10 probe, it still appears to be higher than the breadboard. That is assuming that Wikipedia's 2pf if the small row and the 25pf is the power rails. Mike. |
||
|
|
|
|
|
(permalink) | ||
|
Quote:
Quote:
From the look of things we may be looking at similar capacitances though?. Not that it really matters, get the crystal off the breadboard where it has a chance!. |
|||
|
|
|
|
|
(permalink) |
|
Try to write and read on DS1302 RAM first, if you don't get the right result clear WP bit, if still can't read and write your functions might not be working, if it does read the seconds register, if seconds value is not changing clear CH bit.
|
|
|
|
|
|
|
(permalink) |
|
Does anyone know whether I can make a particular pin (namely RA2) as both an input and an output on a PIC? I am having trouble managing the TRIS register properly in my code. Thanks.
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
Mike. |
||
|
|
|
|
|
(permalink) | |
|
Quote:
As suggested, you need to say what PIC you're using so we can tell you if there are specific requirements for that pin. |
||
|
|
|
|
|
(permalink) |
|
I'm using a PIC18F2620 (not sure if I mentioned it in the first thread of the topic).
|
|
|
|
|
|
|
(permalink) |
|
Did you check that you have ADCON1 = 0x0f as I suggested.
Mike. |
|
|
|
|
|
|
(permalink) |
|
Some good news: I've managed to configure and read out the time properly (hour, minute, second) without starting the clock. However, I am having trouble with when I'm setting up other registers of the chip. My logic is to stop the clock, clear the write protect bit, change whatever register to carry the value I want, and then start the clock again, as shown in the function below:
Code:
// This function sets the time of the Real time Clocks
// Note to self: change it such that it's user controllable
void set_time(void)
{
// Stop the Clock
start_stop_RTC(1);
// Clear the Write protect bit before setting time
write_protect(0);
// Set time
// set_seconds(0);
// set_minutes(9);
// set_hour(9, 1, TWELVEHOUR);
// set_hour(22, 0, TWENTYFOUR);
/* set_date(2);
set_month(1);
set_day(4);*/
set_year(2008);
// Start the clock
start_stop_RTC(0);
// Set the Write protect bit before setting time
//write_protect(1);
}
Code:
// This function starts or stops the Real-time Clock Upon Request
// halt == 1 -> stop the RTC
// halt == 0 -> start the RTC
void start_stop_RTC(short halt)
{
unsigned char current_time;
// retrieve current time
current_time = readbyte(READSEC);
if (halt==1){ // if desired to halt
// set the Clock Halt bit to bit 7 only
writebyte(WRITESEC, current_time | (halt << 7));
}
else if (halt == 0) // if desired to start
{
// clear the Clock Halt bit to bit 7 only
writebyte(WRITESEC, current_time & (0xfe << 7));
}
}
|
|
|
|
|
|
|
(permalink) |
|
I don't read C but it looks like you're clearing the whole register not just the bit. Looks like your supposed to put the seconds in with the start clock bit.
Why would you want to stop the clock once it's running? Not sure if you can even read or write a single bit with SPI. |
|
|
|
|
|
|
(permalink) |
|
Where does the code look like I'm clearing the whole register.
On the other note, I'm not aware of the ability to change the register content without stopping the clock. I probably never want to stop the clock. I don't recall reading anything about the datasheet whether I have to stop the clock before modifying the contents before they change again. |
|
|
|
|
|
|
(permalink) |
|
Shouldn't
writebyte(WRITESEC, current_time & (0xfe << 7)); be writebyte(WRITESEC, current_time & 0x7f); Mike. |
|
|
|
|
|
|
(permalink) |
|
I think they are the same. However, your function call is more efficient since there is one less operation. My function call included an extra operation of shifting the 0 in bit 0 to the left seven times.
|
|
|
|
|
|
|
(permalink) |
|
0xfe shifted left 7 times is 0x7f00, I assume WRITESEC requires a byte and therefore it will get passed zero.
Mike. |
|
|
|
|
|
|
(permalink) |
|
You're still writing over the seconds register no matter how you figure it. You should write the seconds last and let it run. It does all the MDY calcs on its own till year 2100. Are you trying to make it a stopwatch?
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Real Time FLIR Video Feed | digital0ne | Robotics Chat | 3 | 11th April 2004 06:21 PM |
| digital clock setting the time mode | Jay Duluguin | Electronic Projects Design/Ideas/Reviews | 0 | 19th February 2004 10:09 PM |
| real time clock | finst | Micro Controllers | 4 | 17th January 2004 12:11 AM |
| list of Real Time Clock | thendo | Micro Controllers | 2 | 8th November 2003 05:41 PM |
| time clock | gogo01 | Electronic Projects Design/Ideas/Reviews | 2 | 22nd August 2003 05:05 AM |