SPI1 and SPI2 with ethernet on 32MX460F512L

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
microIC
Posts: 82
Joined: 06 Nov 2014 10:45

SPI1 and SPI2 with ethernet on 32MX460F512L

#1 Post by microIC » 09 Mar 2015 21:07

Hi to all,

due problem for more input request, I transfer program from PIC CLICKER BOARD to PIC 32 mikromedia board (display broken)
I use in project click cards: GPS, GSM, 8x8 matrix 2 cards, and serial Ethernet board.
With PIC clicker for communication with 8x8 matrix I use SOFT_SPI, but here for future use I would like to have it on SPI2.
connections are matrix is on SPI2, GSM on UART2 ,GPS on UART1, serial Ethernet board on SPI1

Problem is that serial Ethernet card not working with PIC32 (program is just lightly changed to be used on PIC32). There is no SCK signal generated for neither any signal out of controller on SPI1, except there is CS which is connected on RG14, RST RG13 is HIGH.

Is there any example that ethernet card working on SPI1 with this PIC or there is a problem I use 2 SPI ports. HOW to force SPI_ETHERNET library to use SPI1?

Code: Select all

SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 16, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE)
  delay_ms(100)
  SPI2_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 16, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE)


SPI_Ethernet_Init(myMacAddr, myIpAddr, _SPI_Ethernet_FULLDUPLEX)           ' init ethernet module
SPI_Ethernet_setUserHandlers(@SPI_Ethernet_UserTCP, @SPI_Ethernet_UserUDP) ' set user handlers
' dhcp will not be used here, so use preconfigured addresses
SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr)
when I try to use simple:

Code: Select all

test:
          SPI_Ethernet_CS  =0
          spi1_write(0xAA)
         SPI_Ethernet_CS =1
          delay_ms(5)
          SPI_Ethernet_CS =1
          delay_ms(5)
         goto test
I can see all signal with scope on serial ethernet card chips, so interconnection with PIC32 mikromedia is properly done.

Any hint,
thanks Damir

ps. this is picture with cards together
Attachments
photo_table.JPG
photo_table.JPG (1.95 MiB) Viewed 4247 times

microIC
Posts: 82
Joined: 06 Nov 2014 10:45

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#2 Post by microIC » 09 Mar 2015 21:20

hi to all,

after I wrote previous message I disable SPI2 and check only SPI1 and all work with ethernet card, so looks like a problem with SPI_ethernet library with two different SPI ports.
Mikroelektronika, could you help?

Code: Select all

SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 16, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE)
  delay_ms(100)
  'SPI2 _Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 16, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE)
   httpCounter = 0

  ' set mac address
  myMacAddr[0] = 0x00
  myMacAddr[1] = 0x14
  myMacAddr[2] = 0xA5
  myMacAddr[3] = 0x76
  myMacAddr[4] = 0x19
  myMacAddr[5] = 0x3F

  ' set IP address
  myIpAddr[0] = 193
  myIpAddr[1] = 198
  myIpAddr[2] = 20
  myIpAddr[3] = 61

  ' set gateway address
  gwIpAddr[0]  = 10
  gwIpAddr[1]  = 101
  gwIpAddr[2]  = 14
  gwIpAddr[3]  = 1

  ' set dns address
  dnsIpAddr[0] = 10
  dnsIpAddr[1] = 101
  dnsIpAddr[2] = 14
  dnsIpAddr[3] = 99

  ' set subnet mask
  ipMask[0]    = 255
  ipMask[1]    = 255
  ipMask[2]    = 254
  ipMask[3]    = 0


'   *
'   * starts ENC28J60 with :
'   * reset bit on PORTC.B0
'   * CS bit on PORTC.B1
'   * my MAC & IP address
'   * full duplex
'   *

  SPI_Ethernet_Init(myMacAddr, myIpAddr, _SPI_Ethernet_FULLDUPLEX)           ' init ethernet module
  SPI_Ethernet_setUserHandlers(@SPI_Ethernet_UserTCP, @SPI_Ethernet_UserUDP) ' set user handlers
  ' dhcp will not be used here, so use preconfigured addresses
  SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr)
Thanks, Damir

microIC
Posts: 82
Joined: 06 Nov 2014 10:45

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#3 Post by microIC » 10 Mar 2015 13:41

Hi to all,

I did try with

Code: Select all

SPI_SET_Active(@SPI1_Read, @SPI1_Write)
        ' Sets the SPI1 module active
       SPI_Ethernet_doPacket
       'SPI_SET_Active(@'SPI2_Read, @'SPI2_Write)  ' Sets the SPI2 module active - matrix
but no success,
any help?

Thanks, Damir

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#4 Post by petar.timotijevic » 10 Mar 2015 16:04

Hi Damir,

Please check RST and CS signal pins connections and settings in your code.


Best regards,
Peter

microIC
Posts: 82
Joined: 06 Nov 2014 10:45

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#5 Post by microIC » 10 Mar 2015 16:28

Hi Peter ,
Thans for answer. there is no problem with pin settings:

Code: Select all

dim
  SPI_Ethernet_Rst as sbit at RB14_bit 
  SPI_Ethernet_Rst_Direction as sbit at TRISB14_bit   '
 
  SPI_Ethernet_CS  as sbit at RG14_bit
  SPI_Ethernet_CS_Direction  as sbit at TRISG14_bit
As I say in previous message once I disable SPI2 with putting it just as comment

Code: Select all

'SPI2....
everything on SPI1 where serial ethernet card is connected start to work, so all pins are on proper place and all settings regard SPI1 is OK. problem is when I try to work with both SPI channel.
Is there any problem in if I call SPI_ethernet in program like this:

Code: Select all

SPI_SET_Active(@SPI1_Read, @SPI1_Write)
        ' Sets the SPI1 module active
       SPI_Ethernet_doPacket
       SPI_SET_Active(@'SPI2_Read, @'SPI2_Write)  ' Sets the SPI2 MATRIX module active
Thanks Damir

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#6 Post by petar.timotijevic » 12 Mar 2015 17:45

Hi Damir,

Please can you tell me which compiler version you have?


Best regards,
Peter

microIC
Posts: 82
Joined: 06 Nov 2014 10:45

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#7 Post by microIC » 16 Mar 2015 14:19

Hi Peter,

I already send info within other data to support with open ticket.

Hope someone work on it.

Thanks ,
Damir

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#8 Post by petar.timotijevic » 16 Mar 2015 18:19

Hi Damir,

We are working on a solution for your problem.


Best regards,
Peter

microIC
Posts: 82
Joined: 06 Nov 2014 10:45

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#9 Post by microIC » 15 Apr 2015 11:18

Hi Peter,

thanks for all your help. I try program you send to me and it is working, so now I need to implemet it with my program and test it. Will revert to you soon, I hope.
rgds,
Damir

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: SPI1 and SPI2 with ethernet on 32MX460F512L

#10 Post by petar.timotijevic » 15 Apr 2015 12:11

Hi,
microIC wrote:Hi Peter,

thanks for all your help. I try program you send to me and it is working, so now I need to implemet it with my program and test it. Will revert to you soon, I hope.
rgds,
Damir
Ok, no problem, please send a feedback. My code which I sent you is tested on hardware. Based on my code you can adapt your code for your needs.

I do not think you'll have problems with this.


Best regards,
Peter

Post Reply

Return to “mikroBasic PRO for PIC32 General”