Instructables

doctek

  • Date JoinedJun 10, 2007
  • Total Views389,041
  • Featured %20%

Orangeboard

vinstudy4 years ago
Hi. I m using USI_TWI driver for tiny2313. I want to set clock rate for 100KHz as my slave operates only at 100KHz. I have connected 8MHz external oscillator for tiny2313. Please help me to set the constants in drivers to generate clock @ 100KHz.

Thanks in advance.
doctek (author)  vinstudy4 years ago
Here's the code you need to make the 2313 divide it's clock by 8. This is described in the data sheet (page 30), so have a look there if you need more details. Using a 1MHz clock will result in the I2C bus running at 100KHz max.<br /><br />// Make clock go 4MHz <br /> CLKPR = 0x80; // Initiate write cycle for clock setting<br /> CLKPR = (1<<CLKPS1) | (1<<CLKPS0) ; // Divide Clock by 8<br /><br />Good Luck!<br /><br />