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.

RTC Enabling in TM4C123

Part Number: TM4C123GH6PZ

Tool/software: TI C/C++ Compiler

Hi,

I am not that much aware about the hibernation and RTC. In my project I need to display date and time, whenever the system is turned on. But I don't know how to use RTC for this case. I dont have any idea how I can make this. Please help me if anyone knows about his .

Thank you,

Alphy

  • There is an example using the hibernation module in:

    C:\ti\TivaWare_C_Series-2.1.4.178\examples\boards\dk-tm4c123g\hibernate

    This example was written for a development board that has an OLED display. That board is no longer available. However, you can look at the example and see how they use the hibernation module to sleep and wakeup the part.

    Also look at the simple example programs in section 15.3 of the TivaWare Peripheral Driver User's Guide;

    C:\ti\TivaWare_C_Series-2.1.4.178\docs\SW-TM4C-DRL-UG-2.1.4.178.pdf

  • Hi,

    I am using external FRAM(FM3164) for RTC. I did the program using i2c communication,but I am getting error status as 0x0000000C and the output as garbage value. What this error status means. why it is coming.I am using pull up resistor(4.7K) in SCL and SDA lines.

    I am attaching the code below,

    #define RTC_SLAVE_ADDRESS 0xD0  
    void FRAM_I2C_Config()
    {
    	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
    	while (!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C0));
    	
    	
    	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    	while (!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB));
    	
    	ROM_GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    	ROM_GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);		
    	
    	ROM_GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    	ROM_GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);			 
    	
    	
    	ROM_I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), true);	/* Set clock speed for I2C command , ture=400kHz, false=100kHz*/
    	
    }
    int main()
    {
        system_init();
    while(1)
    {
    
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x00);//RTC Control
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x01);//CAL control
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x02);//seconds
    
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x03);//minute
    
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x04);//Hour
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x05);//Day
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x06);//Date
        TimerBuffer[0]= FRAM_RTCRead_Bck(0x07);//Month
         TimerBuffer[0]= FRAM_RTCRead_Bck(0x08);//Year
    
    }
    }
    
    unsigned char FRAM_RTCRead_Bck(unsigned char Ctrl_reg_addrss)
    {
    	volatile unsigned int error_status = 0;
    	unsigned char Read_Bck_Value = 0;
    	
    	/***************************************SEND WRITE LOCATION TO FRAM********************************************************/
    	ROM_I2CMasterSlaveAddrSet(I2C0_BASE, RTC_SLAVE_ADDRESS, false);		// I2C in Master Transit Mode, true=Receive mode, false=Transit mode
    		
    	ROM_I2CMasterDataPut(I2C0_BASE, Ctrl_reg_addrss);												// Send MSB Address Byte
    	ROM_I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    	while (ROM_I2CMasterBusy(I2C0_BASE));
    	error_status = ROM_I2CMasterErr(I2C0_BASE);
    	
    	ROM_I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
    	while (ROM_I2CMasterBusy(I2C0_BASE));
    	error_status = ROM_I2CMasterErr(I2C0_BASE);
    	
    	/***************************************READ FROM FRAM*********************************************************************/
    	ROM_I2CMasterSlaveAddrSet(I2C0_BASE, RTC_SLAVE_ADDRESS, true);			// I2C in Receive Mode, true=Receive mode, false=Transit mode
    	
    	ROM_I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);		// Start Receive
    	while (ROM_I2CMasterBusy(I2C0_BASE));
    	error_status = ROM_I2CMasterErr(I2C0_BASE);
    	
    	Read_Bck_Value = ROM_I2CMasterDataGet(I2C0_BASE);												// get the Data from the FRAM
    	ROM_I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
    	while (ROM_I2CMasterBusy(I2C0_BASE));
    	error_status = ROM_I2CMasterErr(I2C0_BASE);
    	
    	return Read_Bck_Value;	
    }

    Please let me know why that error is coming and how to solve the issue.

    Thank you,

    Alphy

  • The 0xC error means that the slave did not acknowledge the transmission. I suspect that you are using the wrong slave address. The TivaWare library expects a 7-bit address and it appends the R/W bit. The correct address to use is likely 0x68 (0xD0 >> 1).

  • Hi sir,

    Thank you sir,The slave address what you gave is right only. I am able to read and write data in to the registers. But if I am writing 0x05 to register 0x02 and 0x08 to register 0x03 then while reading from the register I will get 0x00 from register 0x02 and 0x05 from 0x03. similarly for all other registers I am getting previous write values. Why the write value to a register is coming in the next register. Is there any issue with the program.

    Another issue I am facing is with RTC. The RTC is not changing values. I have connected a 32.768KHz crystall at the X1 and X2 terminal of the IC and made the OSEN pin low in programming(Oscillator Enable. When set to ‘1’, the oscillator is halted. When set to ‘0’, the oscillator starts running after tOSC time). but not getting any time change output while reading the register. Is there any other configuration is for enabling the RTC. If anyone in this forum worked on FM3164 FRAM please let me know what we need to do for making the RTC working properly. 

    Thank you,

    Alphy

  • Sorry, Texas Instruments does not make the  FM3164 FRAM device and I have no experience with it. Perhaps some member of this forum has used it before, but I did not see any other posts that referenced this device. Your best bet would be to contact the manufacturer of that device.