PDA

View Full Version : DS1302 Sample Program Problem



Guido
11-12-2006, 09:27 PM
A few years back I found this DS1302 sample program somewhere????? I am trying to get EMIC to speak the actual month, not a numeric number. Anyway after an hour looking for this program I found out that it can only display the month until September.....How can I get it to say the other months?

PJ Allen
11-12-2006, 10:58 PM
Guido said...
...I found out that it ("this program") can only display the month until September
Please explain.· Maybe you meant to tie in the EMIC part of it?·

Guido
11-12-2006, 11:20 PM
If you run this program and set Month to exceed $09 or Basically Month=$10 it will not display the Long version of the Month after September

PJ Allen
11-12-2006, 11:42 PM
Guido said...
If you run this program and set Month to exceed $09 or Basically Month=$10 it will not display the Long version of the Month after September
If you are actually forcing Month = $10, that's Month = 16 (base 10.)· So, that might be your problem.· If you want to use hexadecimal values for October (10), November (11), and December (12), then use·$0A, $0B and $0C, respectively.

Chris Savage
11-12-2006, 11:56 PM
Guido,
·
·· Since the EMIC relies on ASCII strings to speak, you need to send the time information to it in that format.· In SEROUT you can use the HEX formatter to get the time into the correct format.



SEROUT Emic, Baud, [HEX2 hrs, ":", HEX2 mins, ampmFlag, "P"]

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support

Guido
11-13-2006, 03:03 AM
Thanks everyone, but I guess the question I am having is the problem with this program that is attached. It seems that the Lookup Month-1, table can not go past Data Number 9. Why?

Chris Savage
11-13-2006, 04:47 AM
Guido,
·
·· I’ve never seen/used this particular code before, but it appears that while the date is stored in BCD format the program is using the literal value for the lookup.· $10 is October to the DS1302, but it is the 16th element of the lookup table, which doesn’t work.· The value would have to be converted to Decimal before the lookup.· You can do that with the following line of code.



month = (month.NIB1 * 10) + month.NIB0 ' BCD To Decimal

The code I use is located at the following link.· Take care.

http://forums.parallax.com/showthread.php?p=531080

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support

Guido
11-13-2006, 09:54 AM
Thank You Chris, That did the trick!