SPI interface


Closed Thread
Results 1 to 11 of 11

Thread: SPI interface

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default It's alive !

    Well guys I have some good news.

    I returned the original board for replacement, which arrived this morning. I downloaded the article from the ME website and changed the IP settings to reflect that of my home network. Re-compiled the code and loaded into the PIC. Turned off the EP5 and connected the serial ethernet card which was then hooked up to my router. Turned the EP5 back on, got connectivity shown by the LEDS on the card and then tried pinging the IP - Success

    Opened up a web browser, entered the IP and got the sample page to control an LED on port B - worked a treat. I've also tried this with 8, 10 and 12 mhz crystals - all work fine

    So it would seem that the original board was faulty

    Now I just need to work out how to implement a web server in PBP - My research (google ) through up some conversions on posts dating back to 2007 - but most of the links have long since disappeared. - The challenge awaits !

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I may of asked this question before, but us there a way of replicating the html code within PBP.

    This is the example from Mikrobasic (apologies to the owners of this forum for listing competitors products)

    [HTML]program home_auto

    include "home_auto_utils"

    dim myMacAddr as byte[6] ' my MAC address
    myIpAddr as byte[4] ' my IP address
    gwIpAddr as byte[4] ' gateway (router) IP address
    ipMask as byte[4] ' network mask (for example : 255.255.255.0)
    dnsIpAddr as byte[4] ' DNS server IP address

    main:
    ADCON1 = 0x0F ' no analog inputs
    CMCON = 0x07 ' turn off comparators

    PORTB.0 = 0
    TRISB.0 = 0 ' set PORTB.B0 as output (rele control pin)

    indexPage =
    "<html><head><title>mikroElektronika</title></head><body>"+
    "<h3 align=center>MikroElektronika Home Automatization System</h3>"+
    "<form name="+Chr(34)+"input"+Chr(34)+" action="+Chr(34)+"/"+Chr(34)+" method="+
    Chr(34)+"get"+Chr(34)+"><table align=center width=200 bgcolor=#4974E2 border=2><tr>"+
    "<td align=center colspan=2><font size=4 color=white><b>Heat Control</b></font>"+
    "</td></tr><tr><td align=center bgcolor=#4974E2><input name="+Chr(34)+"tst1"+
    Chr(34)+" width=60 type="+Chr(34)+"submit"+Chr(34)+" value="+Chr(34)+"ON"+
    Chr(34)+"></td><td align=center bgcolor=#FFFF00><input name="+Chr(34)+"tst2"+
    Chr(34)+" type="+Chr(34)+"submit"+Chr(34)+" value="+Chr(34)+"OFF"+Chr(34)+
    "></td></tr></table></form></body></html>"

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

    ipMask[0]=255 ipMask[1]=255 ipMask[2]=255 ipMask[3]=0
    myIpAddr[0]=192 myIpAddr[1]=168 myIpAddr[2]=0 myIpAddr[3]=120
    gwIpAddr[0]=192 gwIpAddr[1]=168 gwIpAddr[2]=0 gwIpAddr[3]=1
    dnsIpAddr[0]=192 dnsIpAddr[1]=168 dnsIpAddr[2]=0 dnsIpAddr[3]=1


    ' starts ENC28J60 with: reset bit on PORTC.F0, CS bit on PORTC.F1,
    ' my MAC & IP address, full duplex
    Spi_Init()
    ' full duplex, CRC + MAC Unicast + MAC Broadcast filtering
    Spi_Ethernet_Init (PORTC, 0, PORTC, 1,
    myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX)

    ' dhcp will not be used here, so use preconfigured addresses
    SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr)

    while true ' do forever
    SPI_Ethernet_doPacket() ' process incoming Ethernet packets
    wend
    end.[/HTML]

    As you can see the html is contained within quotes (I had to edit this slightly as the forum displayed the page rather than the source code - the complete code is between the HTML tags), but with the heading "indexpage". Can this be replicated in PBP - or is it a case that Mikrobasic is a much higher level language and PBP simply isn't suitable for this sort of functionality ?
    Last edited by malc-c; - 8th January 2011 at 14:10.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    All doable, but I don't think you can access MikroE library to see how they implement their SPI_Ethernet_x routine huh?

    I think you could probably port some "open source" routine, say C18, to PBP.

    If your time is short, sometimes you may want to stick with a language that already work and learn it rather than reinvent the wheel.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Steve, nice to see you back

    Yeah... I must admit I really want to sick with PBP but with other languages already having library files for this sort of thing, then it is tempting to move over to the dark side !

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    You can change a car transmission with a flat screwdriver, but it need a bit more work Same goes for compiler. Compilers are just tools, there's nothing bad using more than one, use the one that fits your requirement.

    If you feel you may have some requirement for it in the future, I suggest you to port some existing libraries. There's some in C18 on Microchip's website. THere's also some pre-canned solution like ethernet module (Rabbit, Charon, Lantronix etc etc).
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts