CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Missing #ENDIF Error

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Imad84



Joined: 29 May 2006
Posts: 6

View user's profile Send private message

Missing #ENDIF Error
PostPosted: Sun Jun 04, 2006 6:39 am     Reply with quote

Hi all, i am using this code to test the USB communication between an 18F4550 as a device and the host (PC)

#include <18F4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NODEBUG,NOLVP,USBDIV,PLL4,VREGEN,CPUDIV1
#use delay(clock=20000000)

#include <pic18_usb.h> //Microchip PIC18Fxx5x Hardware layer for CCS's PIC USB driver
#include <pic_usb.h> //Configuración del USB y los descriptores para este dispositivo
#include <usb.c> //handles usb setup tokens and get descriptor reports


/////////////////////////////////////////////////////////////////////////////
//
// CCS Library dynamic defines. For dynamic configuration of the CCS Library
// for your application several defines need to be made. See the comments
// at usb.h for more information
//
/////////////////////////////////////////////////////////////////////////////

#define USB_HID_DEVICE FALSE //not using a HID Device
#define USB_EP1_TX_ENABLE USB_ENABLE_BULK //specify the transfer method on EndPoint 1 device --> PC
#define USB_EP1_RX_ENABLE USB_ENABLE_BULK //specify the transfer method on EndPoint 1 PC --> device
#define USB_EP1_TX_SIZE 1 //size to allocate for the tx endpoint 1 buffer (device --> PC)
#define USB_EP1_RX_SIZE 3 //size to allocate for the rx endpoint 1 buffer (PC --> device)


#define mode receive[0]
#define param1 receive[1]
#define param2 receive[2]
#define resultat envoi[0]

void main()

{

int receive[3]; //variables declaration
int envoi[1];

output_low(pin_d0); // indication
output_high(pin_d1);

usb_init(); //USB initialisation

usb_task(); //keeps track of connection sense
usb_wait_for_enumeration(); //infinite loop until device is enumerated

output_low(pin_d1);
output_high(pin_d0); //

while (1)
{
if(usb_enumerated()) // the device is enumerated
{
if(usb_kbhit(1)) //returns true if endpoint 1 contains data from host
{
usb_get_packet(1, receive, 3); //get a packet from endpoint 1 and save it in receive (max ammount of data is 3)

if(mode == 0) // Add Mode
{
resultat = param1 + param2; // Add teh 2 parameters

usb_put_packet(1, envoi, 1, USB_DTS_TOGGLE); //send a packet to the host
}


if(mode == 1) // Mode_Led
{
if (param1 == 0)
{
output_low(pin_d0);
output_low(pin_d1);
}
if (param1 == 1)
{
output_high(pin_d0);
output_low(pin_d1);
}
if (param1 == 2)
{
output_low(pin_d0);
output_high(pin_d1);
}
}


}

}
}
}




i am getting the following error:

Error[14] C:\Documents and Settings\ielrass\Desktop\test.c 164 : Missing #ENDIF


Any Idea?
thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 04, 2006 1:48 pm     Reply with quote

It could be a problem with one of the USB files that you have #included.
Post your version of the compiler. If I have your version, I'll install it
and check those files.
Imad84



Joined: 29 May 2006
Posts: 6

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 5:13 am     Reply with quote

Hello,

The version of the compiler is V3.249

Thanks 4 help
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 7:18 am     Reply with quote

Without looking at the rest of the code, there is something 'screwy', in the includes being selected. 'pic_usb.h', is the incluide for using the 16C765 hardware layer, which is _not_ what is being used on a 18F4550. In fact two hardware layer includes are being made, which I am not suprised causes problems (if you look at the examples, one, or the otehr of these is loaded, according to the chip selected...).
Then, there is no device descriptor being loaded before usb.c. This is the usb_desc_xxx.h include file, where 'xxx', is hid, cdc etc..
I suspect it is the multiple hardware driver, that is causing the problem, with the include file 'going wrong', because another hardware layer is already loaded.

Best Wishes
Ttelmah
Guest







PostPosted: Mon Jun 05, 2006 7:25 am     Reply with quote

As a confirmation, removing the second hardware driver file, adding a descriptor file, and moving the device defines above the load for usb.c, allows this to compile OK.

Best Wishes
Imad84



Joined: 29 May 2006
Posts: 6

View user's profile Send private message

PostPosted: Mon Jun 05, 2006 10:35 am     Reply with quote

Hello Ttelmah,

did u mean removing #include <pic_usb.h> and replace it by
#include<usb_desc_cdc.h>
then put the #include <usb.c> just before the main?

that what i did, i got 73 errors....

Maybe i didn t understand what u mean...

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group