ECIO with CCS compiler

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
Audette
Posts: 11
Joined: Wed Mar 03, 2010 11:24 am
Contact:

ECIO with CCS compiler

Post by Audette »

Hi Guys,

I am trying to use CCS compiler to work with ECIO40. I am using the MPLAB IDE.

Currently all I am trying to do is light up an LED. However, once the PIC is programmed, the onboard LED keeps blinking as if it is in reset - and does not light up the LED I am expecting. My code is as follows;

Code: Select all

#include <18F4455.h>
 
#build(reset=0x800)
#build(interrupt=0x808)
#org 0x0000, 0x07ff  {}  // Reserve space for the bootloader
void bootloader()
{
#asm
nop
#endasm
} 

#use delay(clock=48000000)

void main()
{
    output_low(PIN_D3);
    while(1)
    {
        output_high(PIN_D3);
        delay_ms(1000);
        output_low(PIN_D3);
        delay_ms(1000);
    }
} 
Am I doing anything wrong here - only thing I can think of is it might not be leavig the bootloader space - but I believe the first few lines should acheive this. Does anyone know what I can do to get it to work.

Thanks.

PS> I've set all the configuration bits from the MPLAB IDE hence it is not set in code as fuses - incase any one is wondering.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO with CCS compiler

Post by Benj »

Hello Audette

Im not familiar with the CSS compiler but I don't think you will have to assign the contents of the bootloader. This may be what is causing the ECIO bootloader problems.

What about something like this.

Code: Select all

#include <18F4455.h>

#use delay(clock=48000000)
#org 0x0800

void main()
{
    output_low(PIN_D3);
    while(1)
    {
        output_high(PIN_D3);
        delay_ms(1000);
        output_low(PIN_D3);
        delay_ms(1000);
    }
}
I also noticed that you are not modifying the tris data directiion register. Do your output_low and output_high routines automatically do this for you?

Audette
Posts: 11
Joined: Wed Mar 03, 2010 11:24 am
Contact:

Re: ECIO with CCS compiler

Post by Audette »

Hi Ben, thanks for the reply.

Unfortunately, I cannot just keep org as it gives an error.

I tried it without all the top bit and still getting nothing from it.

yes - I do believe the compiler sets the tris registers according to each command selected.

:(

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO with CCS compiler

Post by Benj »

Hello,

According to this page your code before looks ok.

http://www.ece.msstate.edu/~reese/ece37 ... r/jolt.htm

Maybe try re-arranging to look like the following.

Code: Select all

#build(reset=0x800)
#build(interrupt=0x808)
#org 0x0000,0x07ff
void bootloader() {
#asm
nop
#endasm
} // Reserve space for the bootloader

#include <18F4455.h>
#use delay(clock=48000000)

void main()
{
    output_low(PIN_D3);
    while(1)
    {
        output_high(PIN_D3);
        delay_ms(1000);
        output_low(PIN_D3);
        delay_ms(1000);
    }
}
If this doesn't work then it may be worth posting your hex file as an attachment to the forum and I will see which addresses are being used.

To get the HiTECH compiler to work correctly I had to use the following parameter for the compiler to allow it to generate the hex file so it was compatible with the ECIOprog software.

--OUTPUT=inhx032

This forces the output hex format to be the Microchip hex format. Hopefully there is a similar setting for the CSS compiler.

Audette
Posts: 11
Joined: Wed Mar 03, 2010 11:24 am
Contact:

Re: ECIO with CCS compiler

Post by Audette »

Hi Ben,

thanks for looking into this.

I tried to call the header afterwards as you suggested, but MPLAB then gives an error asking for the header file.

I am attaching the hex file for you to have a look at.

Thanks again for your help.
Attachments
sensor.hex
(429 Bytes) Downloaded 421 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO with CCS compiler

Post by Benj »

Hello,

Using our PPP programming software I have opened the hex file and had a look at the contents.
Hex_Output.JPG
Hex_Output.JPG (51.31 KiB) Viewed 9939 times
As you can see the code is being placed at 0x400 and not 0x800. Not really sure why this is happening. There is nothing in the rest of the file so this is definatley your program occupying this area of the hex file.

Maybe try setting the offset as 0x1000 and see if that makes the code generate at the correct location.

You can download the PPP tool from here if you don't already have it.
http://www.matrixmultimedia.com/software/PPPv3.exe

Audette
Posts: 11
Joined: Wed Mar 03, 2010 11:24 am
Contact:

Re: ECIO with CCS compiler

Post by Audette »

Hi Ben,

OK - when I used PPP, it seemed to start the code at 0800 and not 0400 as was for you. That is strange!

Anyway, I noticed that the configuration bits I had set on MPLAB kept changing each time I built it - which is very strange. So I ended up setting fuses in the code itself but for some reason, the power up timer will not be enabled at all. I am not sure if this matters at all. I've attached the new code below.

If send you the hex code again, will it be possible for you to check if it works with an ECIO40 that you might have?

Its not a problem with the ECIO 'cos I had it working with the C18 compiler, and if I load that program again, it works without a problem.

Code: Select all

#include <18F4455.h>
#FUSES HSPLL
#FUSES USBDIV
#FUSES CPUDIV1
#FUSES PLL1 
#FUSES BROWNOUT
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES PUT  
#FUSES STVREN               
#FUSES NOPBADEN 
#FUSES NOIESO
#FUSES NOFCMEN
#FUSES NOWDT 
#FUSES WDT128
#FUSES CCP2C1
#FUSES VREGEN
#FUSES NOLVP
#FUSES NOLPT1OSC
#FUSES MCLR
#FUSES STVREN
#FUSES NOLVP


#build(reset=0x800)
#build(interrupt=0x808)
#org 0x0000, 0x7ff  {}  // Reserve space for the bootloader
void bootloader()
{
#asm
nop
#endasm
} 

#use delay(clock=48000000)
#use standard_io(D)
void main()
{
    output_low(PIN_D3);
    while(1)
    {
        output_high(PIN_D3);
        delay_ms(1000);
        output_low(PIN_D3);
        delay_ms(1000);
    }
} 

Audette
Posts: 11
Joined: Wed Mar 03, 2010 11:24 am
Contact:

Re: ECIO with CCS compiler

Post by Audette »

Hi Ben,

just to let you know - it seems as if the ECIO keeps unplugging itself from USB after I program it. The device keeps coming and going from device manager. I've unticked the option within power management for the ECIO, but still it keeps doing this for about a minute. The drivers have been installed - so it recognises it as the ECIO40 board. However, after resetting itself several times it ends up with a message saying its an unknown device!!

Could it be something wrong with the driver itself that is causing this?

I will write the same code in C18 compiler and see if I have the same problem and let you know.

Audette

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO with CCS compiler

Post by Benj »

Hello Audette,

Sorry the hex address I was seeing was incorrect as I had a 16F device selected in PPP. Selecting an 18F device showed the hex file started at 0x800 as it should be.

For the HiTech compiler I had to force it to output the hex file as a "Intel HEX with upper address initialization of zero". Is there anything similar available for the CCS compiler?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO with CCS compiler

Post by Benj »

Here are the extra compiler parameters which are required for using the HiTech compiler.

--CODEOFFSET=800h --ROM=default,-0-7FF --OUTPUT=inhx032

Post Reply