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.

TM4C1294NCPDT: How can 8.99 value will be stored in the register as a 0x07???

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL

I'm working on the Ek-TM4C1294XL. So I was trying the i2c . While
configuring the I2C master bus i found the following calculations in the i2c.c driver file (also using i2c driver from Software Development Kit)

ui32I2CClk  = 16000000(Clock Frequency)
ui32SCLFreq = 100000(Standard Mode)
 
    ui32TPR = ((ui32I2CClk + (2 * 10 * ui32SCLFreq) - 1) /
               (2 * 10 * ui32SCLFreq)) - 1;
    HWREG(ui32Base + I2C_O_MTPR) = ui32TPR;
    
    After calculating I got 8.99 value on the paper. But in the MTPR register.
    i'm getting 0x07 value?? How is this possible can anybody please explain me??

Also when i checked datasheet the calculations are different??    

SCL_PERIOD= 2 × (1 +TIMER_PRD) × (SCL_LP+SCL_HP) ×CLK_PRD
For example:
CLK_PRD= 50 ns
TIMER_PRD= 2
SCL_LP=6
SCL_HP=4
yields a SCL frequency of:
1/SCL_PERIOD= 333 Khz

Please can anybody explain??????

  • ui32I2CClk  = 16000000(Clock Frequency)
    ui32SCLFreq = 100000(Standard Mode)


     ui32TPR = ((ui32I2CClk + (2 * 10 * ui32SCLFreq) - 1) / (2 * 10 * ui32SCLFreq)) - 1;

     ui32TPR = ((16000000+ (2 * 10 * 100000) - 1) / (2 * 10 * 100000)) - 1;

     ui32TPR = ((16000000+ 2000000 - 1) / (2000000)) - 1;

    ui32TPR = (17999999 / 2000000) - 1;

    ui32TPR = 8 - 1; //Because ui32TPR is an integer, you get an integer result, the fractional part is discarded (8 instead of 8.9999995)

    ui32TPR = 7;

    Now checking the equation from the datasheet using the values for 16MHz crystal and 100KHz baud rate

    SCL_PERIOD= 2 × (1 +TIMER_PRD) × (SCL_LP+SCL_HP) ×CLK_PRD

    CLK_PRD= 62.5 ns (16 MHz)
    TIMER_PRD= 7 (from calculation above)
    SCL_LP=6
    SCL_HP=4

    SCL_PERIOD= 2 × (1 +7) × (6+4) ×62.5nS

    SCL_PERIOD = 2 x 8 x 10 x 62.5nS;

    SCL_PERIOD = 10,000nS = 10uS (100K baud rate)

  • Hi Bob Crosby

    Thanks a lot for the explanation. Understood now.

    Regards

    Omkar Dixit