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.

TM4C1233H6PM: External oscillator

Part Number: TM4C1233H6PM

If m interfacing a device that use external oscillator. Do I need to run my controller at that rate too. Ds1307 uses crystal oscillator 32.768khz. In order to display it on something like lcd or seven segments..should I run.microcontroller with external osscilator. If not wouldnt there beb timing problems?

  • The frequency you run your microcontroller has nothing to do with the frequency of your other devices (except if you move to more advanced projects which require noise analysis, emi, etc.).
    You just need to make sure the communication between those devices happen in a frequency which both accept.
  • Hello Muhammad

    That is never the case (in my experience). Micro-controllers use a host of interfaces that can run at different clock rates or baud rates and are used to interface to slower devices that may be completely in a different clock domain (and some without one).
  • both ds1307 drivers and seven segment(display) drivers are running well separately. but when i combined them they do not respond.
    do u think there is problem in this?
    int main()
    {

    init_gpio(); //gpio pins for sevensegments
    InitI2C();
    I2Csend(DEVICE_ADDRESS,reg_addr ,0);
    SetTimeDate(45,34,9,4,23,1,14);

    while(1)
    {

    seconds=I2CReceive(DEVICE_ADDRESS,reg_addr++);
    minutes=I2CReceive(DEVICE_ADDRESS,reg_addr++);
    hours=I2CReceive(DEVICE_ADDRESS,reg_addr++);
    days=I2CReceive(DEVICE_ADDRESS,reg_addr++);
    date=I2CReceive(DEVICE_ADDRESS,reg_addr++);
    month=I2CReceive(DEVICE_ADDRESS,reg_addr++);
    year=I2CReceive(DEVICE_ADDRESS,reg_addr);
    reg_addr=0;
    display(seconds,minutes, hours); //this is display driver

    }
    }
  • Hello Muhammad

    How am I supposed to know by looking at some API's what they are doing, what the circuit you have is constructed as?

    Also what is the debug you have done so far to isolate why I2C does not work when a 7 segment display is connected? Please elaborate?
  • if i remove that "display()" and "init_gpio()" simulator(keil) is showing results right i.e seconds minutes etc. but with these two lines that are meant to display ds1307 results on seven segment I2c_data_register is showing zero. master_slave_address_reg is stuck at transmitting showing D0(as it shows D1 for receicing and D0 for transmitting). so i think program is stuck at "Init_I2c". The tasks ahead are not being performed.
  • Hello Muhammad

    Why do you need a simulator for the same when the device is real and exists on a launchpad at minimum.
  • Keil is a debugger for embedded systems...anyway have any idea about my problem?
  • Hello Muhammad

    A simulator is different from debugger. So are you using a physical board or some simulator environment?
  • M using physical board...tm4c123g

  • Hello Muhammad

    Did you probe the I2C SCL and SDA bus? Are the pull up's correctly connected and the bus in idle state shows "H" logic level. If yes, then did you check the transaction itself?
  • ds1307 and seven segment drivers responding accurately separately. Problem starts when i combine them....as described in above code of "int main()" "display() and init_gpio are from seven segment driver all else is from ds1307 driver.
  • Hello Muhammad

    You can understand my predicament. I do not have access to the same devices that you have. I do not have any debug capability to check what is happening. In addition to that a report that they work separately is not sufficient information for me to assist you. You would need to provide me with the debug information that i have asked you so that i can see what could be the issue.
  • master_status_register is showing busy forever. It is stuck in while loop of checking if not busy..i.e.
    while(I2C3_MSTATUS_R & 0x01) {};

    if i remove gpio_init which is meant to initialize pins for 7 segments. all go well for ds1307 . but writing this makes master stuck in there. master_status_reg showing busy forver

  • Hello Muhammad

    Which pins are being used in the function GPIO Init and which pins are being used for I2C3?

    Also please give the full function in your reply. I am suspecting that the configuration in GPIO Init is causing the configuration of the I2C pins to be corrupted.
  • Several forum members past (assisted) in this, "7 Segment LED AND Lcd Time Multiplexed" thread - which was claimed to, "Work" - and then abandoned.

    Has not poster's subject, "External Oscillator" been resolved - each/every (recent) posting here has steered HEAVY/HARD from Oscillator!

  • Hello cb1

    My concern comes from the dreaded DRM "while(I2C3_MSTATUS_R & 0x01) {}; " from the OP's last post. We have in the past faced this issue, advising, guiding posters to stay clear of DRM unless very sure of the intent (some successfully and some not without conflict of interests)
  • Well Amit - I guess you can be concerned w/poster's use of the more complex coding form.

    Still - are we not urged to, "Choose a properly descriptive Forum Title - and (then) stay w/in those bounds?"

    How possibly can this meandering thread be classified now - to serve future readers?
  • pins A and B have been used for GPIO init and D0,D1 for SCL and SDA in i2c3.

    void init_gpio()
    {

    SYSCTL_RCGCGPIO_R |=0x3;

    GPIO_PORTB_DIR_R |= 0xFF; //B0-B7 for a,b,...g,dot
    GPIO_PORTB_DEN_R |= 0xFF;

    GPIO_PORTA_DIR_R |= 0xFC; //A2...A7 for enable pins of segments
    GPIO_PORTA_DEN_R |= 0xFC;
    }
    void InitI2C()
    {
    SYSCTL_RCGCI2C_R |= 0x8;
    SYSCTL_RCGCGPIO_R |=0x8;
    GPIO_PORTD_AFSEL_R |= 0x3; //enable alternate function for PD0 and PD1
    GPIO_PORTD_DEN_R |= 0x00000003; //digital enable PD0 and PD1
    GPIO_PORTD_OD_R |= 0x2; //enable open drain operation for PD1
    GPIO_PORTD_PCTL_R |= (GPIO_PCTL_PD0_SCL | GPIO_PCTL_PD1_SDA); //0x00000033
    I2C3_MCONF_R |=0x10; //initialize I2C3 as master
    I2C3_MTIMEPER_R = 0x7;

    }
  • Hello Muhammad

    So the basic configuration seems to be correct here. Now please provide the I2C capture on a scope to see what is happening on the bus.
  • void I2Csend(unsigned char slave_addr, unsigned char data_addr, unsigned char data)

    {

    while(I2C3_MSTATUS_R & 0x01) {}; //busy

    I2C3_MSA_R = (slave_addr <<1); //configure slave for write

    I2C3_MDATA_R = data_addr;

    I2C3_MCONTROL_R =CMD_BURST_SEND_START;    //0x03

    while(I2C3_MSTATUS_R & 0x01) {}; //this is where it is stuck...not escaping the loop...if gpio_init iscalled in main....this is line...

    I2C3_MDATA_R = data;

    I2C3_MCONTROL_R = CMD_BURST_SEND_CONT; //0x01

    while(I2C3_MSTATUS_R & 0x01) {};

    I2C3_MCONTROL_R = CMD_BURST_SEND_FINISH; //0x05

    while(I2C3_MSTATUS_R & 0x01) {};

    }

    unsigned char I2CReceive(unsigned char slave_addr, unsigned char data_addr) //read from slave device

    {

    unsigned char value=0;

    while(I2C3_MSTATUS_R & 0x01) {}; //wait for master to become idle (last is busy bit)

    I2C3_MSA_R = (slave_addr <<1); //configure slave for write

    I2C3_MDATA_R = data_addr;

    I2C3_MCONTROL_R =CMD_SINGLE_SEND; //0x07

    while(I2C3_MSTATUS_R & 0x01) {};

    I2C3_MSA_R = ((slave_addr<<1) | 0x01); //configure slave for read

    I2C3_MCONTROL_R =CMD_SINGLE_RECEIVE;//0x07

    while(I2C3_MSTATUS_R & 0x01) {};

    value=(unsigned char) I2C3_MDATA_R;

    return value;

    }

  • Hello Muhammad

    Please provide the scope capture!!!!
  • What is scope.capture...I didnt understand..
  • Hello Muhammad

    A Oscilloscope capture of the I2C SDA and SCL pins.