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 DS1307 project error (learning i2c setup)



I want to learn how to use i2c protocol on ti launchpad. I have an rtc ds1307. I have setup a project. I want to setup the control register for1 Hz square pulse that i can see blinking on the pcb.

After a lot o effort that the program was stacking into the check of i2cmasterbusy() function i enabled the loopback mode and the program unstacked.

The problem was not solved tho. In the debug mode the i2creceive funtion gives price of 760  in decimal.the variable that is set to the retrurn of the function goes from zero to 255. I will give you the 2 photos of the program and the whole program. If you find any problem please tell me what i do wrong. 

The  photos: 

The code is in files main.c,delaysetup.c, i2c.c,rtc.c

I ma not giveing the delaysetup cuse is just the interupt of timer0 and the delay function.

I2c.c is:

#include "i2c.h"
#include <stdbool.h>
#include <stdarg.h>
#include <stdint.h>
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/pin_map.h"
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_gpio.h"
#include "inc/hw_i2c.h"


void InitI2C0(void)
{
    //enable GPIO peripheral that contains I2C 0
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    //enable I2C module 0
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);

    //reset module
    SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0);

    // Configure the pin muxing for I2C0 functions on port B2 and B3.
    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);


    // Select the I2C function for these pins.
    GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
    GPIOPinTypeI2C(GPIO_PORTB_BASE,  GPIO_PIN_3);

    // Enable and initialize the I2C0 master module.  Use the system clock for
    // the I2C0 module.  The last parameter sets the I2C data transfer rate.
    // If false the data rate is set to 100kbps and if true the data rate will
    // be set to 400kbps.
    I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);

    // Enable loopback mode.  Loopback mode is a built in feature that is
    // useful for debugging I2C operations.  It internally connects the I2C
    // master and slave terminals, which effectively let's you send data as
    // a master and receive data as a slave.
    // NOTE: For external I2C operation you will need to use external pullups
    // that are stronger than the internal pullups.  Refer to the datasheet for
    // more information.
    //
    HWREG(I2C0_BASE + I2C_O_MCR) |= 0x01;

    //clear I2C FIFOs
    HWREG(I2C0_BASE + I2C_O_FIFOCTL) = 80008000;
}

void I2CSend2(uint8_t slave_addr,uint8_t send_reg_addr,uint8_t send_value){


	I2CMasterSlaveAddrSet(I2C0_BASE,slave_addr,false);

	I2CMasterDataPut(I2C0_BASE,send_reg_addr);

	I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_SINGLE_SEND);

	while(I2CMasterBusy(I2C0_BASE)){

	}

	I2CMasterDataPut(I2C0_BASE,send_value);

	I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_SINGLE_SEND);

	while(I2CMasterBusy(I2C0_BASE)){

	}

}





//sends an I2C command to the specified slave
void I2CSend(uint8_t slave_addr, uint8_t num_of_args, ...)
{
	//    Tell the master module what address it will place on the bus when
	//    communicating with the slave.
	I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false);

	//stores list of variable number of arguments
	va_list vargs;

	//specifies the va_list to "open" and the last fixed argument
	//so vargs knows where to start looking
	va_start(vargs, num_of_args);

	//put data to be sent into FIFO
	I2CMasterDataPut(I2C0_BASE, va_arg(vargs, uint32_t));

	//if there is only one argument, we only need to use the
	//single send I2C function
	if(num_of_args == 1)
	{
		//Initiate send of data from the MCU
		I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);

		// Wait until MCU is done transferring.
		while(I2CMasterBusy(I2C0_BASE));

		//"close" variable argument list
		va_end(vargs);
	}

	//otherwise, we start transmission of multiple bytes on the
	//I2C bus
	else
	{
		//Initiate send of data from the MCU
		I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

		// Wait until MCU is done transferring.
		while(I2CMasterBusy(I2C0_BASE));

		//send num_of_args-2 pieces of data, using the
		//BURST_SEND_CONT command of the I2C module
		uint8_t i;
		for(i = 1 ; i < (num_of_args - 1) ; i++)
		{
			//put next piece of data into I2C FIFO
			I2CMasterDataPut(I2C0_BASE, va_arg(vargs, uint32_t));
			//send next data that was just placed into FIFO
			I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);

			// Wait until MCU is done transferring.
			while(I2CMasterBusy(I2C0_BASE));
		}

		//put last piece of data into I2C FIFO
		I2CMasterDataPut(I2C0_BASE, va_arg(vargs, uint32_t));
		//send next data that was just placed into FIFO
		I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
		// Wait until MCU is done transferring.
		while(I2CMasterBusy(I2C0_BASE));

		//"close" variable args list
		va_end(vargs);
	}
}


//sends an array of data via I2C to the specified slave
void I2CSendString(uint32_t slave_addr, char array[])
{
    // Tell the master module what address it will place on the bus when
    // communicating with the slave.
    I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false);

    //put data to be sent into FIFO
    I2CMasterDataPut(I2C0_BASE, array[0]);

    //if there is only one argument, we only need to use the
    //single send I2C function
    if(array[1] == '\0')
    {
        //Initiate send of data from the MCU
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);

        // Wait until MCU is done transferring.
        while(I2CMasterBusy(I2C0_BASE));
    }

    //otherwise, we start transmission of multiple bytes on the
    //I2C bus
    else
    {
        //Initiate send of data from the MCU
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

        // Wait until MCU is done transferring.
        while(I2CMasterBusy(I2C0_BASE));

        //initialize index into array
        uint8_t i = 1;

        //send num_of_args-2 pieces of data, using the
        //BURST_SEND_CONT command of the I2C module
        while(array[i + 1] != '\0')
        {
            //put next piece of data into I2C FIFO
            I2CMasterDataPut(I2C0_BASE, array[i++]);

            //send next data that was just placed into FIFO
            I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);

            // Wait until MCU is done transferring.
            while(I2CMasterBusy(I2C0_BASE));
        }

        //put last piece of data into I2C FIFO
        I2CMasterDataPut(I2C0_BASE, array[i]);

        //send next data that was just placed into FIFO
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);

        // Wait until MCU is done transferring.
        while(I2CMasterBusy(I2C0_BASE));
    }
}



uint32_t I2CReceive2(uint32_t slave_addr,uint8_t reg){


	I2CMasterSlaveAddrSet(I2C0_BASE,slave_addr,false);

	I2CMasterDataPut(I2C0_BASE,reg);

	I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_SINGLE_SEND);

	while(I2CMasterBusy(I2C0_BASE)){

	}

	I2CMasterSlaveAddrSet(I2C0_BASE,slave_addr,true);

	I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_SINGLE_RECEIVE);

	while(I2CMasterBusy(I2C0_BASE)){

	}

	return I2CMasterDataGet(I2C0_BASE);
}


//read specified register on slave device
uint32_t I2CReceive(uint32_t slave_addr, uint8_t reg)
{
    //specify that we are writing (a register address) to the
    //slave device
    I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false);

    //specify register to be read
    I2CMasterDataPut(I2C0_BASE, reg);

    //send control byte and register address byte to slave device
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

    //wait for MCU to finish transaction
    while(I2CMasterBusy(I2C0_BASE));

    //specify that we are going to read from slave device
    I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, true );

    //send control byte and read from the register we
    //specified
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

    //wait for MCU to finish transaction
    while(I2CMasterBusy(I2C0_BASE));

    //return data pulled from the specified register
    return I2CMasterDataGet(I2C0_BASE);
}

The RTC.c is:

#include "RTC.h"
#include "stdbool.h"
#include <stdint.h>
#include "i2c.h"
#include "time.h"

#define DS1307_ADDRESS  0x68
#define DS1307_CONTROL  0x07
#define DS1307_NVRAM    0x08
#define SECONDS_PER_DAY 86400L
#define OneHertzSQP 0x10
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))

#define SECONDS_FROM_1970_TO_2000 946684800



const uint8_t daysInMonth [] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



uint8_t bcd2bin (uint8_t val) {
	return val - 6 * (val >> 4);
}

uint8_t bin2bcd (uint8_t val) {
	return val + 6 * (val / 10);
}

void RtcDS1307adjust(){

	I2CSend(DS1307_ADDRESS,7,
			myFullCalendar.seconds,myFullCalendar.minutes,myFullCalendar.hour,
			myFullCalendar.dayOfWeek,myFullCalendar.date,myFullCalendar.month,myFullCalendar.year);

}

void RtcSetCTRL(){

    I2CSend(DS1307_ADDRESS,2,DS1307_CONTROL,OneHertzSQP);
//	I2CSend2(DS1307_ADDRESS,DS1307_CONTROL,OneHertzSQP);

}

uint32_t RtcReadCTRL()
{
	return I2CReceive(DS1307_ADDRESS,DS1307_CONTROL);

	//return I2CReceive2(DS1307_ADDRESS,DS1307_CONTROL);
}

void RtcSetTimeStruct2(const char* date, const char* time){


	    // sample input: date = "Dec 26 2009", time = "12:34:56"
	    myFullCalendar.yearOff = conv2d(date + 9);
	    myFullCalendar.year=2000+myFullCalendar.yearOff;


	    // Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
	    switch (date[0]) {
	        case 'J':
	        {
	        	if( date[1] == 'a'){
	        		myFullCalendar.month=1;
	        	}else if (date[2]=='n'){
	        		myFullCalendar.month=6;
	        	}else{
	        		myFullCalendar.month=7;
	        	}
	        }
	        break;

	        case 'F': myFullCalendar.month = 2; break;

	        case 'A':
	        {
	        	if (date[2]=='r'){
	        		myFullCalendar.month=4;
	        	}else{
	        		myFullCalendar.month=8;
	        	}
	        }
	        break;

	        case 'M':
	        {
	        	if (date[2]=='r'){
	        		myFullCalendar.month=3;
	        	}else{
	        		myFullCalendar.month=5;
	        	}
	        }
	        break;

	        case 'S': myFullCalendar.month= 9; break;
	        case 'O': myFullCalendar.month= 10; break;
	        case 'N': myFullCalendar.month= 11; break;
	        case 'D': myFullCalendar.month= 12; break;
	    }

	    myFullCalendar.date = conv2d(date + 4);
	    myFullCalendar.hour = conv2d(time);
	    myFullCalendar.minutes = conv2d(time + 3);
	    myFullCalendar.seconds = conv2d(time + 6);
	    myFullCalendar.dayOfWeek = RtcDayOfWeek();
}

void RtcSetTimeStruct(){

	time_t rawtime;
	struct tm *timeStruct;
	rawtime=time(0);
	timeStruct=localtime(&rawtime);
	myFullCalendar.seconds=timeStruct->tm_sec;
	myFullCalendar.minutes=timeStruct->tm_min;
	myFullCalendar.hour=timeStruct->tm_hour;
	myFullCalendar.date=timeStruct->tm_mday;
	myFullCalendar.month=timeStruct->tm_mon;
	myFullCalendar.year=timeStruct->tm_year+1900;

	myFullCalendar.yearOff=(myFullCalendar.year)-2000;
	myFullCalendar.dayOfWeek=timeStruct->tm_wday;

}
uint8_t RtcDayOfWeek(){
    uint16_t day = date2days(myFullCalendar.yearOff,myFullCalendar.month,myFullCalendar.date);
    return (day + 6) % 7; // Jan 1, 2000 is a Saturday, i.e. returns 6
}



uint8_t conv2d(const char* p) {
    uint8_t v = 0;
    if ('0' <= *p && *p <= '9')
        v = *p - '0';
    return 10 * v + *++p - '0';
}

uint16_t date2days(uint16_t y, uint8_t m, uint8_t d) {
    if (y >= 2000)
        y -= 2000;
    uint16_t days = d;
    uint8_t i;
    for (i = 1; i < m; ++i)
        days += pgm_read_byte(daysInMonth + i - 1);
    if (m > 2 && y % 4 == 0)
        ++days;
    return days + 365 * y + (y + 3) / 4 - 1;
}

And my main.c

#include "stdint.h"
#include "stdbool.h"
#include  <stdarg.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_i2c.h"
#include "inc/hw_gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "DelaySetup.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "inc/tm4c123gh6pm.h"

#include "libs/RTC.h"
#include "libs/DelaySetup.h"
#include "libs/i2c.h"

int main(void) {
	

	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
	uint32_t regctl;


	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);


	TimerConfigure(TIMER0_BASE,TIMER_CFG_A_PERIODIC);

	uint32_t periodLoad;

	periodLoad = (SysCtlClockGet() / 1000);
	TimerLoadSet(TIMER0_BASE,TIMER_A,periodLoad);
	IntEnable(INT_TIMER0A);
	TimerIntEnable(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
	IntMasterEnable();
	TimerEnable(TIMER0_BASE,TIMER_A);

	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
	InitI2C0();
//	RtcSetTimeStruct();
//	RtcDS1307adjust();
	RtcSetCTRL();


	regctl=RtcReadCTRL();

	while(1) {
		if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2))  {
			GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
			delayms(100);
		}else{
			GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
			delayms(100);
		}

	}

}

Can you give me the error???

The last files.DelaySetup.c

#include "DelaySetup.h"
#include "driverlib/timer.h"
#include "inc/hw_memmap.h"


volatile uint32_t timeNow=0;

void Timer0IntHandler(void) {
	// Clear the timer interrupt
	uint32_t status=TimerIntStatus(TIMER0_BASE,true);
	TimerIntClear(TIMER0_BASE, status);
	timeNow++;

	// Read the current state of the GPIO pin and
	// write back the opposite state
//	if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2))  {
//		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
//	}  else  {
//		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
//	}

}


void delayms(uint32_t timeInMSEC){
	volatile uint32_t temp=timeNow;
	while ((timeNow-temp)<timeInMSEC){

	}
}

And the startup file

//*****************************************************************************
//
// Startup code for use with TI's Code Composer Studio.
//
// Copyright (c) 2011-2014 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
//*****************************************************************************

#include <stdint.h>

//*****************************************************************************
//
// Forward declaration of the default fault handlers.
//
//*****************************************************************************
void ResetISR(void);
static void NmiSR(void);
static void FaultISR(void);
static void IntDefaultHandler(void);

//*****************************************************************************
//
// External declaration for the reset handler that is to be called when the
// processor is started
//
//*****************************************************************************
extern void _c_int00(void);
extern void Timer0IntHandler(void);
//*****************************************************************************
//
// Linker variable that marks the top of the stack.
//
//*****************************************************************************
extern uint32_t __STACK_TOP;

//*****************************************************************************
//
// External declarations for the interrupt handlers used by the application.
//
//*****************************************************************************
// To be added by user

//*****************************************************************************
//
// The vector table.  Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000 or at the start of
// the program if located at a start address other than 0.
//
//*****************************************************************************
#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
    (void (*)(void))((uint32_t)&__STACK_TOP),
                                            // The initial stack pointer
    ResetISR,                               // The reset handler
    NmiSR,                                  // The NMI handler
    FaultISR,                               // The hard fault handler
    IntDefaultHandler,                      // The MPU fault handler
    IntDefaultHandler,                      // The bus fault handler
    IntDefaultHandler,                      // The usage fault handler
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    IntDefaultHandler,                      // SVCall handler
    IntDefaultHandler,                      // Debug monitor handler
    0,                                      // Reserved
    IntDefaultHandler,                      // The PendSV handler
    IntDefaultHandler,                      // The SysTick handler
    IntDefaultHandler,                      // GPIO Port A
    IntDefaultHandler,                      // GPIO Port B
    IntDefaultHandler,                      // GPIO Port C
    IntDefaultHandler,                      // GPIO Port D
    IntDefaultHandler,                      // GPIO Port E
    IntDefaultHandler,                      // UART0 Rx and Tx
    IntDefaultHandler,                      // UART1 Rx and Tx
    IntDefaultHandler,                      // SSI0 Rx and Tx
    IntDefaultHandler,                      // I2C0 Master and Slave
    IntDefaultHandler,                      // PWM Fault
    IntDefaultHandler,                      // PWM Generator 0
    IntDefaultHandler,                      // PWM Generator 1
    IntDefaultHandler,                      // PWM Generator 2
    IntDefaultHandler,                      // Quadrature Encoder 0
    IntDefaultHandler,                      // ADC Sequence 0
    IntDefaultHandler,                      // ADC Sequence 1
    IntDefaultHandler,                      // ADC Sequence 2
    IntDefaultHandler,                      // ADC Sequence 3
    IntDefaultHandler,                      // Watchdog timer
    Timer0IntHandler,                      // Timer 0 subtimer A
    IntDefaultHandler,                      // Timer 0 subtimer B
    IntDefaultHandler,                      // Timer 1 subtimer A
    IntDefaultHandler,                      // Timer 1 subtimer B
    IntDefaultHandler,                      // Timer 2 subtimer A
    IntDefaultHandler,                      // Timer 2 subtimer B
    IntDefaultHandler,                      // Analog Comparator 0
    IntDefaultHandler,                      // Analog Comparator 1
    IntDefaultHandler,                      // Analog Comparator 2
    IntDefaultHandler,                      // System Control (PLL, OSC, BO)
    IntDefaultHandler,                      // FLASH Control
    IntDefaultHandler,                      // GPIO Port F
    IntDefaultHandler,                      // GPIO Port G
    IntDefaultHandler,                      // GPIO Port H
    IntDefaultHandler,                      // UART2 Rx and Tx
    IntDefaultHandler,                      // SSI1 Rx and Tx
    IntDefaultHandler,                      // Timer 3 subtimer A
    IntDefaultHandler,                      // Timer 3 subtimer B
    IntDefaultHandler,                      // I2C1 Master and Slave
    IntDefaultHandler,                      // Quadrature Encoder 1
    IntDefaultHandler,                      // CAN0
    IntDefaultHandler,                      // CAN1
    0,                                      // Reserved
    0,                                      // Reserved
    IntDefaultHandler,                      // Hibernate
    IntDefaultHandler,                      // USB0
    IntDefaultHandler,                      // PWM Generator 3
    IntDefaultHandler,                      // uDMA Software Transfer
    IntDefaultHandler,                      // uDMA Error
    IntDefaultHandler,                      // ADC1 Sequence 0
    IntDefaultHandler,                      // ADC1 Sequence 1
    IntDefaultHandler,                      // ADC1 Sequence 2
    IntDefaultHandler,                      // ADC1 Sequence 3
    0,                                      // Reserved
    0,                                      // Reserved
    IntDefaultHandler,                      // GPIO Port J
    IntDefaultHandler,                      // GPIO Port K
    IntDefaultHandler,                      // GPIO Port L
    IntDefaultHandler,                      // SSI2 Rx and Tx
    IntDefaultHandler,                      // SSI3 Rx and Tx
    IntDefaultHandler,                      // UART3 Rx and Tx
    IntDefaultHandler,                      // UART4 Rx and Tx
    IntDefaultHandler,                      // UART5 Rx and Tx
    IntDefaultHandler,                      // UART6 Rx and Tx
    IntDefaultHandler,                      // UART7 Rx and Tx
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    IntDefaultHandler,                      // I2C2 Master and Slave
    IntDefaultHandler,                      // I2C3 Master and Slave
    IntDefaultHandler,                      // Timer 4 subtimer A
    IntDefaultHandler,                      // Timer 4 subtimer B
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    0,                                      // Reserved
    IntDefaultHandler,                      // Timer 5 subtimer A
    IntDefaultHandler,                      // Timer 5 subtimer B
    IntDefaultHandler,                      // Wide Timer 0 subtimer A
    IntDefaultHandler,                      // Wide Timer 0 subtimer B
    IntDefaultHandler,                      // Wide Timer 1 subtimer A
    IntDefaultHandler,                      // Wide Timer 1 subtimer B
    IntDefaultHandler,                      // Wide Timer 2 subtimer A
    IntDefaultHandler,                      // Wide Timer 2 subtimer B
    IntDefaultHandler,                      // Wide Timer 3 subtimer A
    IntDefaultHandler,                      // Wide Timer 3 subtimer B
    IntDefaultHandler,                      // Wide Timer 4 subtimer A
    IntDefaultHandler,                      // Wide Timer 4 subtimer B
    IntDefaultHandler,                      // Wide Timer 5 subtimer A
    IntDefaultHandler,                      // Wide Timer 5 subtimer B
    IntDefaultHandler,                      // FPU
    0,                                      // Reserved
    0,                                      // Reserved
    IntDefaultHandler,                      // I2C4 Master and Slave
    IntDefaultHandler,                      // I2C5 Master and Slave
    IntDefaultHandler,                      // GPIO Port M
    IntDefaultHandler,                      // GPIO Port N
    IntDefaultHandler,                      // Quadrature Encoder 2
    0,                                      // Reserved
    0,                                      // Reserved
    IntDefaultHandler,                      // GPIO Port P (Summary or P0)
    IntDefaultHandler,                      // GPIO Port P1
    IntDefaultHandler,                      // GPIO Port P2
    IntDefaultHandler,                      // GPIO Port P3
    IntDefaultHandler,                      // GPIO Port P4
    IntDefaultHandler,                      // GPIO Port P5
    IntDefaultHandler,                      // GPIO Port P6
    IntDefaultHandler,                      // GPIO Port P7
    IntDefaultHandler,                      // GPIO Port Q (Summary or Q0)
    IntDefaultHandler,                      // GPIO Port Q1
    IntDefaultHandler,                      // GPIO Port Q2
    IntDefaultHandler,                      // GPIO Port Q3
    IntDefaultHandler,                      // GPIO Port Q4
    IntDefaultHandler,                      // GPIO Port Q5
    IntDefaultHandler,                      // GPIO Port Q6
    IntDefaultHandler,                      // GPIO Port Q7
    IntDefaultHandler,                      // GPIO Port R
    IntDefaultHandler,                      // GPIO Port S
    IntDefaultHandler,                      // PWM 1 Generator 0
    IntDefaultHandler,                      // PWM 1 Generator 1
    IntDefaultHandler,                      // PWM 1 Generator 2
    IntDefaultHandler,                      // PWM 1 Generator 3
    IntDefaultHandler                       // PWM 1 Fault
};

//*****************************************************************************
//
// This is the code that gets called when the processor first starts execution
// following a reset event.  Only the absolutely necessary set is performed,
// after which the application supplied entry() routine is called.  Any fancy
// actions (such as making decisions based on the reset cause register, and
// resetting the bits in that register) are left solely in the hands of the
// application.
//
//*****************************************************************************
void
ResetISR(void)
{
    //
    // Jump to the CCS C initialization routine.  This will enable the
    // floating-point unit as well, so that does not need to be done here.
    //
    __asm("    .global _c_int00\n"
          "    b.w     _c_int00");
}

//*****************************************************************************
//
// This is the code that gets called when the processor receives a NMI.  This
// simply enters an infinite loop, preserving the system state for examination
// by a debugger.
//
//*****************************************************************************
static void
NmiSR(void)
{
    //
    // Enter an infinite loop.
    //
    while(1)
    {
    }
}

//*****************************************************************************
//
// This is the code that gets called when the processor receives a fault
// interrupt.  This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
FaultISR(void)
{
    //
    // Enter an infinite loop.
    //
    while(1)
    {
    }
}

//*****************************************************************************
//
// This is the code that gets called when the processor receives an unexpected
// interrupt.  This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void
IntDefaultHandler(void)
{
    //
    // Go into an infinite loop.
    //
    while(1)
    {
    }
}

  • Hello Kyriakos

    The regctl which holds the value from the I2CRecieve shows the values as 255 or 0 between the two snapshots? Can you explain the same?

    Also it seems that the value of RTCReadCtrl is being read as an address. Can you check in the map file the location in flash where the function is being located?

    Regards
    Amit
  • when the program starts the value is 0 and when the program goes into while loop it gets the value 255.
    The registrer address for the control is 0x07 so i have to write to this address a value of 0x10 to get an 1Hz square pulse and this is the same value i am trying to read. what do you mean about checking in the map file the location in flash can you explain more in order to undestand? Thaank you.

  • Hello Kyriakos

    In CCS there is a map file which created which shows where the functions are placed in the memory. This would be created in the CCS project -> Debug directory by the name of YOUR_PROJECT_NAME.map

    It is a text file that can be opened in CCS. Search for the function name in the map file and the address at which the function is placed.

    Regards
    Amit
  • There address is: 000002f9 RtcReadCTRL what can i understand by this?
  • Hello Kyriakos

    0x2F9 in decimal is 761. The Address of the function is 760 which matches up (remeber in Cortex M4 the LSB of the address is a byte incremented)

    Regards
    Amit
  • Can you explain more? What does that mean about the return value 255? And how can i make it work properly?

    Where is the bug that makes the program not to send 0x10 and send 0xFF(255)?

  • Hi,

    Your expression to watch is defined as unsigned int (*)() which is a pointer to a function returning unsigned integer. Defined as this, the debugger cannot execute your function and return to you 255 or whatever is the result.

    More, as you show, its address falls within the vector interrpts area so the question(s): did you defined the function RtcReadCTRL as interrupt vector ? Did you added a startup_xxx.c file to your project?

    Please specify the micro used and the tools.

    Petrei

  • I use one interupt handler. As you see in main.c i have a Timer that has a frequency of 1000Hz (1msec) and in the while loop i use this in the delayms(uint32_t thedelay) function. I will give you the interupt delaysetup.c file.In the startup file i have just declared the Timer0handler nothing else.So no the RtcReadCtl is defined in the rct.c file as you saw.I am giving you the files.Is there any way that i can give file without giving it as code but as file in order to make posts smaller? i will add the files in the main post.

    I want to add something more.In all of the c files i cn include header(i mean all headers stdbool etc).At the header files of all .c file(i2c.h,DelaySetup.h,RTC.h etc) i can not use the autocomplete list with ctl+space. It does not give me the list like it can not find any to include. I can write the headers myself and then it recognize int_types etc and project compiles normally.

  • Hi,

    The best solution to manage many big files is to .zip them and insert the package, to be examined by helpers.

    At the moment, the .map file will be useful to be examined.

    I will take a more close look to your posted files. Just now, my comments about your function: it is unusual its address, since the space occupied by interrupt vectors could be bigger than that address, so the need to see the map file.

    If it is an ordinary function , its address should be even; only interrupt functions get odd addresses.

    Petrei

  • ******************************************************************************
                      TI ARM Linker PC v5.1.9                      
    ******************************************************************************
    >> Linked Sun Dec 07 17:19:17 2014
    
    OUTPUT FILE NAME:   <I2C.out>
    ENTRY POINT SYMBOL: "_c_int00"  address: 000015c9
    
    
    MEMORY CONFIGURATION
    
             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      FLASH                 00000000   00040000  00001af0  0003e510  R  X
      SRAM                  20000000   00008000  0000037c  00007c84  RW X
    
    
    SEGMENT ALLOCATION MAP
    
    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
    00000000    00000000    00001af0   00001af0    r-x
      00000000    00000000    0000026c   0000026c    r-- .intvecs
      0000026c    0000026c    00001664   00001664    r-x .text
      000018d0    000018d0    000001d8   000001d8    r-- .const
      00001aa8    00001aa8    00000048   00000048    r-- .cinit
    20000000    20000000    0000037c   00000000    rw-
      20000000    20000000    00000200   00000000    rw- .stack
      20000200    20000200    00000130   00000000    rw- .bss
      20000330    20000330    0000004c   00000000    rw- .data
    
    
    SECTION ALLOCATION MAP
    
     output                                  attributes/
    section   page    origin      length       input sections
    --------  ----  ----------  ----------   ----------------
    .init_array 
    *          0    00000000    00000000     UNINITIALIZED
    
    .intvecs   0    00000000    0000026c     
                      00000000    0000026c     tm4c123gh6pm_startup_ccs.obj (.intvecs)
    
    .text      0    0000026c    00001664     
                      0000026c    00000328     RTC.obj (.text)
                      00000594    00000300     i2c.obj (.text)
                      00000894    000002d4     rtsv7M4_T_le_v4SPD16_eabi.lib : trgdrv.obj (.text)
                      00000b68    000002a8                                   : mktime.obj (.text)
                      00000e10    00000130     driverlib.lib : gpio.obj (.text:GPIOPadConfigSet)
                      00000f40    00000118                   : sysctl.obj (.text:SysCtlClockGet)
                      00001058    000000f0                   : sysctl.obj (.text:SysCtlClockSet)
                      00001148    000000a8     main.obj (.text)
                      000011f0    0000009c     rtsv7M4_T_le_v4SPD16_eabi.lib : memcpy_t2.obj (.text)
                      0000128c    00000094                                   : auto_init.obj (.text)
                      00001320    00000060     driverlib.lib : interrupt.obj (.text:IntEnable)
                      00001380    00000060     rtsv7M4_T_le_v4SPD16_eabi.lib : trgmsg.obj (.text)
                      000013e0    0000005e                                   : copy_decompress_rle.obj (.text)
                      0000143e    00000002     --HOLE-- [fill = 0]
                      00001440    0000005c     driverlib.lib : timer.obj (.text:TimerConfigure)
                      0000149c    00000050                   : sysctl.obj (.text:SysCtlPeripheralReset)
                      000014ec    0000004c     rtsv7M4_T_le_v4SPD16_eabi.lib : localtim.obj (.text)
                      00001538    00000048     driverlib.lib : gpio.obj (.text:GPIOPinConfigure)
                      00001580    00000048                   : i2c.obj (.text:I2CMasterInitExpClk)
                      000015c8    00000048     rtsv7M4_T_le_v4SPD16_eabi.lib : boot.obj (.text)
                      00001610    00000044     DelaySetup.obj (.text)
                      00001654    00000044     rtsv7M4_T_le_v4SPD16_eabi.lib : cpy_tbl.obj (.text)
                      00001698    00000044                                   : exit.obj (.text)
                      000016dc    00000042                                   : u_divt2.obj (.text)
                      0000171e    00000002     --HOLE-- [fill = 0]
                      00001720    00000034     driverlib.lib : sysctl.obj (.text:SysCtlPeripheralEnable)
                      00001754    0000002a                   : gpio.obj (.text:GPIODirModeSet)
                      0000177e    00000018                   : gpio.obj (.text:GPIOPinTypeGPIOOutput)
                      00001796    00000002     --HOLE-- [fill = 0]
                      00001798    00000018     rtsv7M4_T_le_v4SPD16_eabi.lib : args_main.obj (.text)
                      000017b0    00000014                                   : _lock.obj (.text)
                      000017c4    00000014                                   : strlen.obj (.text)
                      000017d8    00000012     driverlib.lib : gpio.obj (.text:GPIOPinTypeI2C)
                      000017ea    00000012                   : gpio.obj (.text:GPIOPinTypeI2CSCL)
                      000017fc    00000012                   : timer.obj (.text:TimerLoadSet)
                      0000180e    00000012     rtsv7M4_T_le_v4SPD16_eabi.lib : copy_zero_init.obj (.text:decompress:ZI)
                      00001820    00000010                                   : strcpy.obj (.text)
                      00001830    0000000e     driverlib.lib : timer.obj (.text:TimerEnable)
                      0000183e    0000000e     rtsv7M4_T_le_v4SPD16_eabi.lib : copy_decompress_none.obj (.text:decompress:none)
                      0000184c    0000000e                                   : time.obj (.text)
                      0000185a    0000000c     driverlib.lib : cpu.obj (.text:CPUcpsie)
                      00001866    0000000c     tm4c123gh6pm_startup_ccs.obj (.text)
                      00001872    0000000a     driverlib.lib : i2c.obj (.text:I2CMasterEnable)
                      0000187c    0000000a                   : interrupt.obj (.text:IntMasterEnable)
                      00001886    0000000a                   : timer.obj (.text:TimerIntStatus)
                      00001890    00000008                   : i2c.obj (.text:I2CMasterBusy)
                      00001898    00000008                   : i2c.obj (.text:I2CMasterSlaveAddrSet)
                      000018a0    00000008                   : timer.obj (.text:TimerIntEnable)
                      000018a8    00000006                   : gpio.obj (.text:GPIOPinRead)
                      000018ae    00000006                   : gpio.obj (.text:GPIOPinWrite)
                      000018b4    00000006                   : sysctl.obj (.text:SysCtlDelay)
                      000018ba    00000006     rtsv7M4_T_le_v4SPD16_eabi.lib : copy_decompress_rle.obj (.text:decompress:rle24)
                      000018c0    00000004     driverlib.lib : i2c.obj (.text:I2CMasterControl)
                      000018c4    00000004                   : i2c.obj (.text:I2CMasterDataGet)
                      000018c8    00000004                   : i2c.obj (.text:I2CMasterDataPut)
                      000018cc    00000004                   : timer.obj (.text:TimerIntClear)
    
    .const     0    000018d0    000001d8     
                      000018d0    00000090     driverlib.lib : gpio.obj (.const:g_pui32GPIOBaseAddrs)
                      00001960    00000070                   : interrupt.obj (.const)
                      000019d0    0000006c                   : sysctl.obj (.const:g_pui32Xtals)
                      00001a3c    00000060     rtsv7M4_T_le_v4SPD16_eabi.lib : mktime.obj (.const)
                      00001a9c    0000000c     RTC.obj (.const:.string)
    
    .cinit     0    00001aa8    00000048     
                      00001aa8    00000022     (.cinit..data.load) [load image, compression = rle]
                      00001aca    00000002     --HOLE-- [fill = 0]
                      00001acc    0000000c     (__TI_handler_table)
                      00001ad8    00000008     (.cinit..bss.load) [load image, compression = zero_init]
                      00001ae0    00000010     (__TI_cinit_table)
    
    .stack     0    20000000    00000200     UNINITIALIZED
                      20000000    00000200     --HOLE--
    
    .bss       0    20000200    00000130     UNINITIALIZED
                      20000200    00000120     rtsv7M4_T_le_v4SPD16_eabi.lib : trgmsg.obj (.bss:__CIOBUF_)
                      20000320    00000008     (.common:myFullCalendar)
                      20000328    00000008     (.common:parmbuf)
    
    .data      0    20000330    0000004c     UNINITIALIZED
                      20000330    00000024     rtsv7M4_T_le_v4SPD16_eabi.lib : localtim.obj (.data:local_tm)
                      20000354    00000010                                   : tmzone.obj (.data)
                      20000364    00000008                                   : _lock.obj (.data)
                      2000036c    00000008                                   : exit.obj (.data)
                      20000374    00000004     DelaySetup.obj (.data)
                      20000378    00000004     rtsv7M4_T_le_v4SPD16_eabi.lib : stkdepth_vars.obj (.data)
    
    
    LINKER GENERATED COPY TABLES
    
    __TI_cinit_table @ 00001ae0 records: 2, size/record: 8, table size: 16
    	.data: load addr=00001aa8, load size=00000022 bytes, run addr=20000330, run size=0000004c bytes, compression=rle
    	.bss: load addr=00001ad8, load size=00000008 bytes, run addr=20000200, run size=00000130 bytes, compression=zero_init
    
    
    LINKER GENERATED HANDLER TABLE
    
    __TI_handler_table @ 00001acc records: 3, size/record: 4, table size: 12
    	index: 0, handler: __TI_decompress_rle24
    	index: 1, handler: __TI_decompress_none
    	index: 2, handler: __TI_zero_init
    
    
    GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name 
    
    address    name
    --------   ----
    00001699   C$$EXIT
    000013ab   C$$IO$$
    0000185b   CPUcpsie
    00001755   GPIODirModeSet
    00000e11   GPIOPadConfigSet
    00001539   GPIOPinConfigure
    000018a9   GPIOPinRead
    0000177f   GPIOPinTypeGPIOOutput
    000017d9   GPIOPinTypeI2C
    000017eb   GPIOPinTypeI2CSCL
    000018af   GPIOPinWrite
    00000b21   HOSTclock
    00000ae9   HOSTclose
    00000aab   HOSTgetenv
    00000a4f   HOSTlseek
    000009fd   HOSTopen
    000009b1   HOSTread
    00000953   HOSTrename
    00000919   HOSTtime
    000008e1   HOSTunlink
    00000895   HOSTwrite
    00001891   I2CMasterBusy
    000018c1   I2CMasterControl
    000018c5   I2CMasterDataGet
    000018c9   I2CMasterDataPut
    00001873   I2CMasterEnable
    00001581   I2CMasterInitExpClk
    00001899   I2CMasterSlaveAddrSet
    00000819   I2CReceive
    000007c3   I2CReceive2
    00000639   I2CSend
    000005e5   I2CSend2
    0000071d   I2CSendString
    00000595   InitI2C0
    00001321   IntEnable
    0000187d   IntMasterEnable
    00001867   ResetISR
    000002b1   RtcDS1307adjust
    0000045d   RtcDayOfWeek
    000002f9   RtcReadCTRL
    000002e9   RtcSetCTRL
    00000401   RtcSetTimeStruct
    00000305   RtcSetTimeStruct2
    UNDEFED    SHT$$INIT_ARRAY$$Base
    UNDEFED    SHT$$INIT_ARRAY$$Limit
    00000f41   SysCtlClockGet
    00001059   SysCtlClockSet
    000018b5   SysCtlDelay
    00001721   SysCtlPeripheralEnable
    0000149d   SysCtlPeripheralReset
    00001611   Timer0IntHandler
    00001441   TimerConfigure
    00001831   TimerEnable
    000018cd   TimerIntClear
    000018a1   TimerIntEnable
    00001887   TimerIntStatus
    000017fd   TimerLoadSet
    20000200   __CIOBUF_
    20000200   __STACK_END
    00000200   __STACK_SIZE
    20000200   __STACK_TOP
    00001ae0   __TI_CINIT_Base
    00001af0   __TI_CINIT_Limit
    00001acc   __TI_Handler_Table_Base
    00001ad8   __TI_Handler_Table_Limit
    00000001   __TI_args_main
    0000128d   __TI_auto_init
    2000036c   __TI_cleanup_ptr
    0000183f   __TI_decompress_none
    000018bb   __TI_decompress_rle24
    20000370   __TI_dtors_ptr
    000013af   __TI_readmsg
    00001aa8   __TI_static_base__
    00001381   __TI_writemsg
    0000180f   __TI_zero_init
    000011f1   __aeabi_memcpy
    000011f1   __aeabi_memcpy4
    000011f1   __aeabi_memcpy8
    000016dd   __aeabi_uidiv
    000016dd   __aeabi_uidivmod
    ffffffff   __binit__
    ffffffff   __c_args__
    20000000   __stack
    00001799   _args_main
    000015c9   _c_int00
    20000364   _lock
    000017bf   _nop
    000017b7   _register_lock
    000017b1   _register_unlock
    20000354   _tz
    20000368   _unlock
    0000169d   abort
    0000026d   bcd2bin
    0000028d   bin2bcd
    ffffffff   binit
    00000487   conv2d
    00001655   copy_in
    000004c9   date2days
    00001a9c   daysInMonth
    0000162f   delayms
    000016a5   exit
    00000000   g_pfnVectors
    000014ed   localtime
    00001149   main
    20000378   main_func_sp
    000011f1   memcpy
    00000b69   mktime
    20000320   myFullCalendar
    00001821   strcpy
    000017c5   strlen
    0000184d   time
    20000374   timeNow
    
    
    GLOBAL SYMBOLS: SORTED BY Symbol Address 
    
    address    name
    --------   ----
    00000000   g_pfnVectors
    00000001   __TI_args_main
    00000200   __STACK_SIZE
    0000026d   bcd2bin
    0000028d   bin2bcd
    000002b1   RtcDS1307adjust
    000002e9   RtcSetCTRL
    000002f9   RtcReadCTRL
    00000305   RtcSetTimeStruct2
    00000401   RtcSetTimeStruct
    0000045d   RtcDayOfWeek
    00000487   conv2d
    000004c9   date2days
    00000595   InitI2C0
    000005e5   I2CSend2
    00000639   I2CSend
    0000071d   I2CSendString
    000007c3   I2CReceive2
    00000819   I2CReceive
    00000895   HOSTwrite
    000008e1   HOSTunlink
    00000919   HOSTtime
    00000953   HOSTrename
    000009b1   HOSTread
    000009fd   HOSTopen
    00000a4f   HOSTlseek
    00000aab   HOSTgetenv
    00000ae9   HOSTclose
    00000b21   HOSTclock
    00000b69   mktime
    00000e11   GPIOPadConfigSet
    00000f41   SysCtlClockGet
    00001059   SysCtlClockSet
    00001149   main
    000011f1   __aeabi_memcpy
    000011f1   __aeabi_memcpy4
    000011f1   __aeabi_memcpy8
    000011f1   memcpy
    0000128d   __TI_auto_init
    00001321   IntEnable
    00001381   __TI_writemsg
    000013ab   C$$IO$$
    000013af   __TI_readmsg
    00001441   TimerConfigure
    0000149d   SysCtlPeripheralReset
    000014ed   localtime
    00001539   GPIOPinConfigure
    00001581   I2CMasterInitExpClk
    000015c9   _c_int00
    00001611   Timer0IntHandler
    0000162f   delayms
    00001655   copy_in
    00001699   C$$EXIT
    0000169d   abort
    000016a5   exit
    000016dd   __aeabi_uidiv
    000016dd   __aeabi_uidivmod
    00001721   SysCtlPeripheralEnable
    00001755   GPIODirModeSet
    0000177f   GPIOPinTypeGPIOOutput
    00001799   _args_main
    000017b1   _register_unlock
    000017b7   _register_lock
    000017bf   _nop
    000017c5   strlen
    000017d9   GPIOPinTypeI2C
    000017eb   GPIOPinTypeI2CSCL
    000017fd   TimerLoadSet
    0000180f   __TI_zero_init
    00001821   strcpy
    00001831   TimerEnable
    0000183f   __TI_decompress_none
    0000184d   time
    0000185b   CPUcpsie
    00001867   ResetISR
    00001873   I2CMasterEnable
    0000187d   IntMasterEnable
    00001887   TimerIntStatus
    00001891   I2CMasterBusy
    00001899   I2CMasterSlaveAddrSet
    000018a1   TimerIntEnable
    000018a9   GPIOPinRead
    000018af   GPIOPinWrite
    000018b5   SysCtlDelay
    000018bb   __TI_decompress_rle24
    000018c1   I2CMasterControl
    000018c5   I2CMasterDataGet
    000018c9   I2CMasterDataPut
    000018cd   TimerIntClear
    00001a9c   daysInMonth
    00001aa8   __TI_static_base__
    00001acc   __TI_Handler_Table_Base
    00001ad8   __TI_Handler_Table_Limit
    00001ae0   __TI_CINIT_Base
    00001af0   __TI_CINIT_Limit
    20000000   __stack
    20000200   __CIOBUF_
    20000200   __STACK_END
    20000200   __STACK_TOP
    20000320   myFullCalendar
    20000354   _tz
    20000364   _lock
    20000368   _unlock
    2000036c   __TI_cleanup_ptr
    20000370   __TI_dtors_ptr
    20000374   timeNow
    20000378   main_func_sp
    ffffffff   __binit__
    ffffffff   __c_args__
    ffffffff   binit
    UNDEFED    SHT$$INIT_ARRAY$$Base
    UNDEFED    SHT$$INIT_ARRAY$$Limit
    
    [112 symbols]
    

    Sorry i  could not find a way to insert file and not media.How can i do it.I can also add the map file

  • Hi,

    Your map file seems to be OK. Now related to your initial question, I think it is good to use something my_var=my_function() and to watch my_var instead of a pointer to function.

    As for inserting a .zip file, try inserting media (the second one, looking like a film and select uploading from your computer, disregard dimension - I tried and seems to upload, but not really inserted.

    Petrei

  • My basic question: is there any error on enabling the i2c protocol and in the way I call the receive and send functions in order to be logical to get this values? But more basic is this a good configuration ? ( it shouldn't be so hard :(.   )

  • Hello Kyriakos,

    The configuration of I2C is correct. As Petrei did mention, it is the manner in which the variable has to be read by the function and monitoring of the return value instead that of the function's address in memory map

    Regards
    Amit
  • So let me get it clear. There is no problem in the initialisation of the i2c protocol, and there is not any problem on send and receive functions.
    But if there is no problem in the send and receive function the setCTRL and readCTRL functions should work correctly. Except that i have a led on the rtc.So if the correct value is set to the register i will understand it even if the readCTRL value had a problem. So since he conf is good is there any problem on the send and receive?

  • I have managed to make it almost work. I have reconnected the pullup resistors for thew sda and scl of the i2c and i have deleted the loopback function. I manage to read the register 0x07 before  writing to it and the value was 0x03.After this i wrote to the register the value 0x10 and then i read it back. The value was correct but it did not opened the square pulse. Though it was correct the value i read the pulse is not working. So is it any chance that the read was not good? I am giving a photo that in order to prove that the correct value for 1Hz square pulse is 0x10.

    Is it possible to read a correct value and still the register not to be set?

  • Hello Kyriakos

    Yes, the chance of reading the correct value and not seeing an output could be of the following reasons

    1. Is the OUT Pin connected to the Pull Up as described in the DS1307 data sheet

    2. Is the slave device some how faulty? Won't be surprised as it often happens...

    Regards

    Amit