Page 1 of 1

I2C_Init parameter

Posted: 22 Jan 2008 17:28
by Chris Yeager
So how exactally do I determine what this parameter maps to on a PIC specifications sheet.
I see parameters in the mikroBasic book like SPI_Init(100000)
I see nothing in the datasheet referring to 100000 (one hundred thousand) as being any kind of configuration parameter.
The PIC18F452 has a control register called SSPCON1, it has 3 bits SSPM3:SSPM0 that allow configuration of the mode and speed reletive to the Fosc. So I just want to know how the 100000 maps to these settings, or if it even does?


Thanks,

Chris

Re: I2C_Init parameter

Posted: 23 Jan 2008 09:59
by rajkovic
Chris Yeager wrote:So how exactally do I determine what this parameter maps to on a PIC specifications sheet.
I see parameters in the mikroBasic book like SPI_Init(100000)
I see nothing in the datasheet referring to 100000 (one hundred thousand) as being any kind of configuration parameter.
The PIC18F452 has a control register called SSPCON1, it has 3 bits SSPM3:SSPM0 that allow configuration of the mode and speed reletive to the Fosc. So I just want to know how the 100000 maps to these settings, or if it even does?


Thanks,

Chris

Spi_init does not receive parameters. I assume that you meant I2C_init
like you have stated in subject.
If you read carefully datasheet you will see that speed setting is

clock = FOSC / (4 * (SSPADD+1))

SSPADD which is SSP Baud Rate Reload Register in I2C Master mode
which means that you control baudrate by writing corresponding value to it which is calculated based on argument that you have passed to init.

Posted: 23 Jan 2008 15:46
by Chris Yeager
You are right I did mean the I2C_Init. But I still dont know what the argument being passed to it means. The small amount of documentation on this I2C_Init command doesn't explain what the parameter is.
So I guess that is my real question.

Please explain the meaning of the parameter passed to the I2C_Init function. Is it the "clock" value you described in the previous answer?

Thanks,

Chris

Posted: 23 Jan 2008 15:59
by rmteo
Chris, look at the data sheet for a PIC or a serial EEPROM such as a 24LC16. I2C supports different clock rates such as 100Khz and 400KHz. The parameter pass in the I2C_Init is the clock rate in Hz.

Similar in concept to the baud rate with the USART_Init function.