2005-07-18 06:06 AM
2011-05-17 03:07 AM
Hello,
I am having a problem where by using the sample timer 0 files my I2C gets slowed down. I am using timer 2 for sound generation, timer 1 for Uarts 0 and 1 and timer 0 for pausing for 1ms, 10ms, and 1 sec delays. If I increase the countdown spead of timer 0 my I2C will speed up hugely. If I have it set to the default for ''upsd3200_timer.c'' then my I2C goes unbelievably slow. I have tried running at different frequencies for the I2C, it doesn't seem to matter. Why would a timer effect the I2C speed? Is it based off of a timer? I have tried to download the PDF file Application Note regaurding I2C for the DK3234 off of ST's website but the link does not work. Could someone send me the PDF maybe? Here is my init routine for the I2C: P3SFS |= 0xC0; // Enable P3.7 for SCL, P3.6 for SDA S2CON |= 0x03; // Setup I2C-2 for 300KHz (36MHz XTAL) i2c_init_flag = 1; // set init done flag i2c_timeout_flag = 0; // clear timeout error flag PX1 = 0; // set low priority for INT1 IPA |= 0x02; // set high priority for EI2C IEA |= 0x02; // set EI2C I2C Int. Enable bit here is my init routine for timer 0: EA = 0; /* disable interrupts */ timer0_tick = 0; TR0 = 0; /* stop timer 0 */ TMOD &= 0xF0; /* clear timer 0 mode bits - bottom 4 bits */ TMOD |= 0x01; /* put timer 0 into 16-bit no prescale */ // Calculate timer rollover to be 10ms periods (100hz) timer0_value = 0x10000 - ( ((FREQ_OSC * 5L) / 6L) - 17L); TL0 = (timer0_value & 0x00FF); TH0 = (timer0_value >> 8); PT0 = 1; /* set high priority interrupt for timer 0 */ ET0 = 1; /* enable timer 0 interrupt */ TR0 = 1; /* start timer 0 */ EA = 1; /* enable interrupts */ Thanks in advance!!2011-05-17 03:07 AM
Never mind. I figured out my own problem.
The code I was using would poll the interrupt, and it would do it every 1 ms. It used timer 0 to detect when 1ms had passed, and when timer 0 is running true to 1ms, milliseconds add up to a delay. If someone else is having this problem, I hope it helps them. Also here is the correct link to the upsd 32xx I2C PDF: http://www.st.com/stonline/books/ascii/docs/10494.htm ST has the incorrect link on their site. Eric