Shop OBEX P1 Docs P2 Docs Learn Events
Convert to decimal — Parallax Forums

Convert to decimal

ArchArch Posts: 2
edited 2012-09-11 21:01 in General Discussion
Using the template from DS1302template.bs2, and then having it the real time clock displayed on my LCD appmod Terminal, however I am missing the digits 8 and 9. Meaning that for the seconds, it goes from 40, 41, 42, 43, 44, 45, 46, 47, 40, 41, 50.
I understand that it has got to do with converting of BCD to decimal value. I've tried a few ways that were mentioned in the previous forum.. none of them really works.. Could anyone advise me on this?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-05 09:25
    I don't have a copy of DS1302template.bs2, so I can't advise you specifically, but it looks like you're dropping the 8 bit of the least significant digit of the seconds value. Somewhere you have a mask of $7 when you should have a mask of $F. Post your code as an attachment to a reply.
  • ArchArch Posts: 2
    edited 2012-09-05 18:06
    Mike Green wrote: »
    I don't have a copy of DS1302template.bs2, so I can't advise you specifically, but it looks like you're dropping the 8 bit of the least significant digit of the seconds value. Somewhere you have a mask of $7 when you should have a mask of $F. Post your code as an attachment to a reply.

    Thanks Mike. I've attached my file. Anyway, This is the portion of the code where LCD_Date is displaced. Many thanks :)

    LCD_Date:
    GOSUB ClearScreen

    value = (hrs >> 4) * 10 + (hrs & $0F) 'To set the display of hours to LCD appmod, convert to ASCII before writiing.
    GOSUB C_ASCII

    value = (mins >> 4) * 10 + (mins & $0F)
    GOSUB C_ASCII


    value = (secs >> 4) * 10 + (secs & $0F)
    GOSUB C_ASCII

    RETURN
  • Mike GreenMike Green Posts: 23,101
    edited 2012-09-11 21:01
    I can't see anything wrong with the code that writes the time values to the LCD. Maybe one of the connections to the LCD is bad. Try writing characters like "@ABCDEFGHIJKLMNO". The "HIJKLMNO" may show up as "@ABCDEFG" if I'm right.

    char = "@"
    call Write_LCD_Char
    char = "A"
    call Write_LCD_Char
    ' ... and so on
Sign In or Register to comment.