This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR5739 RTC_B automatic BCD conversion



I noticed in the User's Guide (pages 368, 369) that the new RTC_B has 2 new registers. BIN2BCD and BCD2BIN. That's fantastic! I tried them out with the experimentors kit and sure enough, writing a 9999 to BCD2BIN converts it to 0x270Fh.  Writing 0x1234h to BIN2BCD results in 4660. Am I being fooled by the debugger? Is that the true operaton of those registers?

Can you give us a little more detail about it. For example, how many cycles does it take to convert? I assume it is using ACLK but if it is hardware, the conversioin result would be ready immediately.

Andy

  • Andy said:
    Is that the true operaton of those registers?

    Yes, it is. Converting numericalk values to BCD and back is a relatively complex task. The MSP has some base support for BCD values on assembly level, but this applies to addition of BCD values (0x05+0x05 is 0x10 in BCD and not 0x0a (which is no valid BCD value). However, transforming one into the other is not supported. Hopwever, it is sometimes needed, and I think it was a good idea to add these two registers to the RTC module, which deals with BCD values in calendar mode (easy to use for display purposes, but time-consuming to convert if you want do tt do math).
    And since you cannot switch the RTC between the two modes without resetting it...

    Andy said:
    how many cycles does it take to convert

    I don't think it takes any cycle(s). In hardware, it is a relatively easy task. I dare to say that as soon as you write to the register, the result can be read. However, the minimum time is two cycles, even if you're using indexed mode with prleoaded address and such. You simply cannot read it faster after writing to it.

     

**Attention** This is a public forum