Need help compiling an example

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Need help compiling an example

Post by malc c » Sat Jan 01, 2011 5:39 pm

Background:
I have an EasyPIC5 development board, and generally use PicBASIC Pro for writing programs. For Christmas I've just treated myself to the serial ethernet board based on the ENC28J60 chip that MikroElectronica do.

I've downloaded the example codes from the MikroElectronica site but couldn't get that to work (no ping, UPD or HTTP response). The lights on the board seem to respond (the activity LED flashes from time to time but can't get any comms between the PIC and the add-on board. In order to see if the board is faulty I've been scouring the net trying to find HEX files that I could try. And found Swordfish :)

However, having installed the SE version, tested it with the blinky LED program, and then downloaded the example code and program http://www.sfcompiler.co.uk/wiki/pmwiki ... r.Ethernet I then found that trying to compile this code exceeds the limit of the SE version.

Could someone please help me out and compile the example and e-mail me the resulting HEX file ( [email protected]). The example seems to use DHCP, but if it needs hard coding the details are as follows:

IP 192.168.0.175
Sub 255.255.255.0
dns 192.168.0.1
GW 192.168.0.1

Thanks in advance

Malcolm

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Sun Jan 02, 2011 1:20 pm

Malcolm,

You'd probably be best off sticking with whatever compiler you intend to use, and trying to get it to work with it. The chances of getting a precompiled hex file to work with your setup is pretty slim... you never even mentioned which chip you're using.

Not that I would ever recommend it, but since you say you use PicbasicPro, those folks have some files for supporting the ENC28J60, or perhaps better yet the MikroE tools since you're using all their hardware.

The Swordfish libraries work, but as you found out, you need the full version. Also, for a decent network implementation, you need a pretty large chip in terms of ram/flash no matter which tools you end up using.

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Post by malc c » Sun Jan 02, 2011 2:19 pm

Jerry, thanks for posting a reply.

To be honest I didn't go into the specifics in my post as I intended to do so to anyone who made contact via e-mail offering help. My post did get a response and we have been trying to get this device working.

For info, the Chips I've tried are 18F4580, 18F4520 - both of which have plenty of memory.

I have also tried examples from the ME website which i couldn't get working, and before I went through the RMA procedure looked for examples in other compilers to try to see if it was something screwey with the ME example.

It seems that I've been unlucky and received a duff board as none of the examples (be that SF, PBP or MB) will work (no ping, UPD, nothing), and intend returning it for exchange after the bank holiday.

Regards

Malcolm

dbracken
Registered User
Registered User
Posts: 9
Joined: Fri Mar 09, 2007 7:23 pm
Location: Christchurch, NZ

Post by dbracken » Sun Jan 02, 2011 9:31 pm

Malcolm,
A few things.
Just wanted to check that the ethernet card is connected to port C via the bottom left connector.
The example code on the card's page (http://www.mikroe.com/eng/downloads/get ... amples.zip) is for an 16F877A (mentioned in a pbp file).
Jumper 1 on the card is set for the correct voltage.
One of the pbas files in the zip above mentions the board hanging if a slow clock is used. What clock are you using?

Apart from that, having the lights working is positive and so check the dhcp log on you router for activity. It might be the case that it gets an IP address but goes awol after that. Sadly most home based routers tend not say much beyond "yeah, I gave something an address" so disable dhcp on the router (if you can) and install a small dhcp server on your pc. I'm assuming you have the ethernet board plugged into a switch and/or then into the router. Either way the dhcp broadcast traffic will end up at your pc. That said, the most direct route would be via an ethernet crossover cable into your pc but this is not essential. http://tftpd32.jounin.net/ is a decent free dhcp server. Once confgured, power the board on and check for dhcp activity. You might want to watch for traffic using wireshark (http://www.wireshark.org/download.html) but if you do, close down any browsers and IM progs to cut down on traffic. In a nut shell, is there any dhcp activity? If there is, then consider a few 232 based debug lines to see how far through the code you get.

If after all that there's no dhcp activity, then yes, it sounds poorly.

Apologies if any of the above is teaching your granny how to suck eggs.

Dave.

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Mon Jan 03, 2011 10:24 am

Hi Malc,

I don't think you have a bad board. It is most likley a code issue. Yoou either need to get the full version of SF or use MikroBasic. Its hard to get people to compile code for you when it not clear what you want to do.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Post by malc c » Mon Jan 03, 2011 2:09 pm

dbracken wrote:Malcolm,
A few things.
Just wanted to check that the ethernet card is connected to port C via the bottom left connector.
Hi Dave, yes the add-on board is connected to the PORT C header on the left of the EasyPIC5 board.
dbracken wrote:The example code on the card's page (http://www.mikroe.com/eng/downloads/get ... amples.zip) is for an 16F877A (mentioned in a pbp file).
That is correct, and I've tried with a 16F877A but get the same results
dbracken wrote:Jumper 1 on the card is set for the correct voltage.
One of the pbas files in the zip above mentions the board hanging if a slow clock is used. What clock are you using?
Yes, I've set the jumper to 5v. I've tried 10Mhz, 12Mhz, 6Mhz, and 4Mhz crystals in all examples. I've also tried the sample files for serial ethernet using 18F chips (18F4520) as per this article http://www.mikroe.com/eng/downloads/get ... _02_09.pdf

The notes in the header states

Code: Select all

target devices :
' *      any PIC with integrated SPI and more than 4 Kb ROM memory
' *      32 to 40 MHz clock is recommended to get from 8 to 10 Mhz SPI clock,
' *      otherwise PIC should be clocked by ENC clock output due to ENC silicon bug in SPI hardware
' *      if you try lower PIC clock speed, don't be surprised if the board hang or miss some requests !
This is why I've used a 10Mhz crystal and set the fuse to HS_PLL when squirting the HEX to the PIC, this should make the PIC run at 40Mhz with a 10Mhz SPI clock. To check the PIC runs, I compiled a simple blinky LED program and that works fine.

I also have some PBP code for a project that uses a DS1307 RTC module via I2C, but uses the same pins on PORTC of the PIC - this works fine when the Ethernet module is removed and the RTC module fitted in its place and the project code loaded - my thinking is that this proves physical connectivity between the PORTC header on the board and the pins of the PIC.

I then swap the add-on boards back, re-load any of the sample code for the 18F4520 and restart the EP5 board. On the Ethernet board the power LED lights, the connectivity LED lights and then there is a few pulses on the activity LED. Looking at the router (Sky Broadband) and the attached D-LINK switch, the activity LED seems to flash when all the activity LEDs on the router / switch flash together (difficult to explain really).
dbracken wrote:Apart from that, having the lights working is positive and so check the dhcp log on you router for activity. It might be the case that it gets an IP address but goes awol after that. Sadly most home based routers tend not say much beyond "yeah, I gave something an address" so disable dhcp on the router (if you can) and install a small dhcp server on your pc. I'm assuming you have the ethernet board plugged into a switch and/or then into the router. Either way the dhcp broadcast traffic will end up at your pc.
I checked the limited log section and it seems by default there is no logging - can't see how to change the default either - so there is nothing shown. I can look at what is connected to the router - and plugging in the card doesn't show it's mac or IP address

I also have a utility that scans the network for attached devices but that only showed up the other computers in the house (3 kids !). That's not to say it wasn't on the network, this scanner didn't pick up the TV, Skybox or Xbox, all of which are hard wired to the network.

dbracken wrote:That said, the most direct route would be via an ethernet crossover cable into your pc but this is not essential. http://tftpd32.jounin.net/ is a decent free dhcp server. Once confgured, power the board on and check for dhcp activity. You might want to watch for traffic using wireshark (http://www.wireshark.org/download.html) but if you do, close down any browsers and IM progs to cut down on traffic. In a nut shell, is there any dhcp activity? If there is, then consider a few 232 based debug lines to see how far through the code you get.
Thanks - I would give that a go, but having communicated with the supplier they are shipping a replacement out to me tomorrow, so the suspected faulty unit is now packed up ready for posting. - If the replacement fails then I'll download wireshark and get a cross over cable and see what's what
dbracken wrote:If after all that there's no dhcp activity, then yes, it sounds poorly.
this was my suspicion...
dbracken wrote:Apologies if any of the above is teaching your granny how to suck eggs.
Not in the slightest - whilst I have a basic understanding and can set up static IP addressed and troubleshoot PC issues.... but when it comes to things like PICs and all this stuff I am out of my depth if it's not plug and play ! - so your comments and help is well appreciated.

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Post by malc c » Mon Jan 03, 2011 2:12 pm

CharlieM wrote:Hi Malc,

I don't think you have a bad board. It is most likley a code issue. Yoou either need to get the full version of SF or use MikroBasic. Its hard to get people to compile code for you when it not clear what you want to do.
Charlie, you could be right.... I might invest in SF, but funds are tight at the moment due to a family emergency.

By the way, thanks for your assistance

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Mon Jan 03, 2011 10:33 pm

Hi Malcolm,

Sorry I could not be more help. I might have to get one of those boards and have a go.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Post by malc c » Tue Jan 04, 2011 11:41 am

Charlie, I appreciate the effort you put in to provide test files for me to try. I still have them, and when the replacement board arrives will try them again.

Normally most add on boards are plug and play once the code is loaded. A project I've been developing over the past year needed a time reference, and the RTC2 module was used. It worked 1st time with some sample PBP code, which was what I was expecting with this serial ethernet board.

For those that may be interested, here is the end result of that project

Image
Image

Basically four pulse proportional thermostats, a twin channel light unit and a programmable timer for both heat and light functions, which can be set via a PC application. Used to keep my snakes at the correct environment. Regretfully it will never get into production due to the regulations in having the thing meet all the CE directives, but it's been fun and I'm still developing it (net access was to be the next stage :)

Guys, just wanted to say thanks for making me feel welcome on this forum, and for your input and assistance - Thank you

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Tue Jan 04, 2011 11:56 am

Well Malc that is a really professional job. What compiler is the firmware written in?
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Tue Jan 04, 2011 2:17 pm

Malc, very cool project. Can I ask where you got the case?
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Post by malc c » Tue Jan 04, 2011 6:59 pm

Thanks for the comments guys I am really proud of the end result.

The case is from Maplin's priced at just under £10.

Charlie,
The project firmware is written in PicBasicPro. I had help with the code from two of the senior PicBasicPro forum members as we were also developing the PID include files so the process can be used in other projects, so it was a case of back scratching as I did all the testing of the routines in the real world. The remaining 50% of the code was all my own work :)

The 18F4580 is running at 48Mhz, has four independent pulse proportional thermostats (using PID routines) which use DS18B20 1-wire devices as the sensors. The DS1307 provides the clock for on / off times for the two light channels, and also for four independent night time periods so you can program a night time drop in temperatures if required. The device has RS232 port to communicate with a PC application that was kindly written for me by a chap in Canada in Liberty Basic, although the unit can be set up using the LCD and three tactile buttons. This software however does allow for easy changes and setting up. The final item is a 4 channel alarm, where independent thresholds for each thermostat can be set. Total code size is around 22K

I used Diptrace to draw up the schematic and laid out the PCB myself. I then e-mailed the gerbers to PCBWang in HongKong who done an fantastic job of producing 6 PCB's. The idea was to make the remaining 5 up and sell them to members of a reptile forum who had shown a lot of interest. However that was before I researched the directives for selling electrical items in the EU and penalties if found guilty of breaching them !! - However my local trading standards office have given me some guidelines... but at the end of the day its interpretation of the law and what side of the bed the judge got out of on the day that means it could go either way !

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Post by malc c » Sat Jan 08, 2011 12:38 pm

Guys, small update for you

I returned the add-on board for replacement, and the new one arrived today. I downloaded the MikroElectronica's sample files, edited the IP settings, re-compiled and loaded the HEX - I can ping the new IP address and using the webserver example, control a LED on the easyPIC 5 board.

I then loaded the hex file that Charlie e-mailed me and by testing with the board turned on or off, pin the IP address that was configured in the code. The best bit is that it works with 8,10 and 12 Mhz crystals too.

So it would point to the original serial ethernet board being faulty.

Thanks guys for your support.

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Sat Jan 08, 2011 1:12 pm

Hi Malc,

That is good to hear.I never would have guessed it was faulty hardware. Thanks for updating us.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

malc c
Posts: 10
Joined: Sat Jan 01, 2011 5:26 pm

Post by malc c » Sat Jan 08, 2011 2:18 pm

Well after trying nearly every sample code I could find I was hedging towards a problem with the hardware... this now confirms it.

Thanks for all your help. The challenge now is to try and get some of the excellent functionality Swordfish offers ported to PicBASIC :shock:

Post Reply