how to use the second i2c port in PIC18F97J60 FAM

General discussion on mikroBasic.
Post Reply
Author
Message
sqjcknorf
Posts: 35
Joined: 16 Feb 2006 03:02

how to use the second i2c port in PIC18F97J60 FAM

#1 Post by sqjcknorf » 30 Oct 2008 11:24

As the PIC18F97J60 has two serial ports, two i2c/sp ports and the ethernet port, I would like to use all those capabilities in a very small board where there is:

1 - SD/MMC SLOT (on the first i2c/sp port)
1 - Ethernet port
1 - i2c eeprom + RTC (on the second i2c/sp port)
1 - rs232 port (usart2)
1 - USB port (via RS232 converter like ft232-usart1)

Now, by usart lib I can simply access the two rs232, but I'm not able to address/use the second i2c channel (via mikrobasic)...
Is there anyone can help me?
Kind regards
SN

P.S.: when ended i hope to share the project...

Raslan
Posts: 758
Joined: 02 Jul 2006 12:31
Location: Syria & Finland
Contact:

#2 Post by Raslan » 30 Oct 2008 16:58

How about posting your code so we can see what is going on?
I am learning in this forum a lot from the others' problems and experinces...
"Give me a fish, I eat for a day. Teach me how to fish, I eat for a life time."

sqjcknorf
Posts: 35
Joined: 16 Feb 2006 03:02

No code at this time

#3 Post by sqjcknorf » 31 Oct 2008 11:10

In this period I'm working to hw setup.
May be I'm not full documented on I2C libraries. I thought that as for usart library, where for example there are commands as this:

usart_write_text2.... to write on usart2

or

usart_write_text1.... to write on usart1

there where commands as I2C_Start2 to send a start sequence to the second I2C port, and so on....

The I2C library in mikrobasic, works only with I2C on C port!!!

does anyone know how I have to solve this problem?

Jan Rune
Posts: 416
Joined: 21 Oct 2005 23:04
Location: Oslo, Norway

#4 Post by Jan Rune » 31 Oct 2008 11:33

Taken from the Mikrobasic help file:

Note: Certain PICmicros with two I²C modules, such as P18F8722, require you to specify the module you want to use. Simply append the number 1 or 2 to a I2C. For example, I2C2_Wr Also, for the sake of backward compabitility with previous compiler versions and easier code management, MCU's with multiple I2C modules have I²C library which is identical to I2C1 (i.e. you can use I2C_Init instead of I2C1_Init for I²C operations).

sqjcknorf
Posts: 35
Joined: 16 Feb 2006 03:02

#5 Post by sqjcknorf » 01 Nov 2008 00:30

:shock:
I said may be I was not well documented...
:roll:
thans and kind regards...

sqjcknorf
Posts: 35
Joined: 16 Feb 2006 03:02

HELP USING MMC/SD

#6 Post by sqjcknorf » 10 Nov 2008 09:29

Hi, as I posted in my previous posts, I'm going to use for the first time MMC/SD with a 18F97J60.
I connected MMC to the PORTC (c3-c4-c5) SPI Signals, and connected CS on PORTD.2 both with a 4.7kohm pull up resistor on all signals and either with or without resistor on SDO, but MMC is not detected.
Here is the simple code I used.

Code: Select all

program MMC_SD_Detect

main:
usart_init1(19200)
USART_WRITE_TEXT1("INIT  ")
  while true
       spi1_Init_Advanced(MASTER_OSC_DIV16, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH)
       if Mmc_Init(PORTD, 2) = 0 then
          USART_WRITE_TEXT1("    Detected")
       else
          USART_WRITE_TEXT1("Not Detected")
       end if
       Delay_ms(1000)
  wend
end.
May be I'm doing something wrong in connections or may be I need to set up PIC ...

sqjcknorf
Posts: 35
Joined: 16 Feb 2006 03:02

#7 Post by sqjcknorf » 10 Nov 2008 10:42

I forgot I'm using a PIC 18F97J60 @ 25 MHZ...

Post Reply

Return to “mikroBasic General”