I2C_Init parameter

General discussion on mikroBasic.
Post Reply
Author
Message
Chris Yeager
Posts: 73
Joined: 21 Sep 2005 04:23

I2C_Init parameter

#1 Post by Chris Yeager » 22 Jan 2008 17:28

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

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

Re: I2C_Init parameter

#2 Post by rajkovic » 23 Jan 2008 09:59

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.

Chris Yeager
Posts: 73
Joined: 21 Sep 2005 04:23

#3 Post by Chris Yeager » 23 Jan 2008 15:46

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

rmteo
Posts: 1330
Joined: 19 Oct 2006 17:46
Location: Colorado, USA

#4 Post by rmteo » 23 Jan 2008 15:59

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.

Post Reply

Return to “mikroBasic General”