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

Urgent!! facing problem PIC 18f2550

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



Joined: 26 May 2009
Posts: 12

View user's profile Send private message

Urgent!! facing problem PIC 18f2550
PostPosted: Tue May 26, 2009 2:13 am     Reply with quote

Can anyone check for me the code below:
Code:
#include <18F2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL3,CPUDIV1,VREGEN
#use delay(clock=48000000)
#define USB_HID_DEVICE     FALSE             
#define USB_EP1_TX_ENABLE  USB_ENABLE_BULK   
#define USB_EP1_RX_ENABLE  USB_ENABLE_BULK   
#define USB_EP1_TX_SIZE    1                 
#define USB_EP1_RX_SIZE    3                 
#include <pic18_usb.h>     
#include <PicUSB.h>       
#include <usb.c>           
#define LEDV    PIN_B6
#define LEDR    PIN_B7
#define LED_ON  output_high
#define LED_OFF output_low

#define modo      recibe[0]
#define param1    recibe[1]
#define param2    recibe[2]
#define resultado envia[0]


void main(void) {

   int8 recibe[3];
   int8 envia[1];
   LED_OFF(LEDV);                 
   LED_ON(LEDR);
   usb_init();
   usb_task();                     
   usb_wait_for_enumeration();     
  // LED_ON(PIN_A0); 
   LED_OFF(LEDR);
   LED_ON(LEDV);                   
   SET_TRIS_A( 0xFF);
// LED_ON(PIN_B0);
  while (TRUE)
   {
      if(usb_enumerated())         
      {
        if (usb_kbhit(1))         
         {
              usb_get_packet(1, recibe, 3);
           
            if (modo == 0 || modo == 1)
            {
             if (INPUT_STATE(PIN_A1)& INPUT_STATE(PIN_A2))
            { 
               resultado =3; 
               usb_put_packet(1, envia, 1, USB_DTS_TOGGLE);
             
             }
             if (!INPUT_STATE(PIN_A1) & INPUT_STATE(PIN_A2))
             {
             resultado =2;

               usb_put_packet(1, envia, 1, USB_DTS_TOGGLE);
            }

           
         }
      }
   }
}
}
//modo == 0 || modo == 1

#include <E:\car project\USB Interface\USB\CCS\PicUSB.h>

void main()
{
   int8 receivedPacket[2];
   output_B (0x80);
   usb_init();
   usb_task();
   usb_wait_for_enumeration();
   output_B (0x40);

   while (TRUE)
   {
     if (usb_enumerated())
      {
         if (usb_kbhit(1))
            {
               usb_get_packet(1,receivedPacket,2);
               switch(receivedPacket[0])
               {
                case 0x00;
                output_B(0xff);
                break;

                case 0x01;
                output_B(0x00);
                break;
                }
            }
       }
     }
}
It is about usb microcontroller.
URGENT!! Thanks
Ttelmah
Guest







PostPosted: Tue May 26, 2009 8:39 am     Reply with quote

You mean aside from the fact it has two "main" routines, and can never work therefore.....

Best Wishes
khwoo



Joined: 26 May 2009
Posts: 12

View user's profile Send private message

PostPosted: Tue May 26, 2009 7:08 pm     Reply with quote

Ttelmah wrote:
You mean aside from the fact it has two "main" routines, and can never work therefore.....

Best Wishes


Oh I see, so who can help me?
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Tue May 26, 2009 7:53 pm     Reply with quote

khwoo wrote:
...Oh I see, so who can help me?

No, I don't think you do see. This forum is composed of volunteers. The way to get volunteers to help you is to make it as easy as possible for them to help you. That means doing as much of the work yourself first. You can't expect someone else to spend time analyzing your code if you are not willing to spend the time yourself. Say what you think the code ought to do. Say what steps you have already taken to verify whether it is doing it or not. Say what you observed the code to do in testing. If you are not willing to do these things, no one is going to bother trying to help you.
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
khwoo



Joined: 26 May 2009
Posts: 12

View user's profile Send private message

PostPosted: Wed May 27, 2009 4:49 am     Reply with quote

RLScott wrote:
khwoo wrote:
...Oh I see, so who can help me?

No, I don't think you do see. This forum is composed of volunteers. The way to get volunteers to help you is to make it as easy as possible for them to help you. That means doing as much of the work yourself first. You can't expect someone else to spend time analyzing your code if you are not willing to spend the time yourself. Say what you think the code ought to do. Say what steps you have already taken to verify whether it is doing it or not. Say what you observed the code to do in testing. If you are not willing to do these things, no one is going to bother trying to help you.


Okay, sorry for that, I will try to solve it by myself. Thanks anyway. Smile
Ttelmah
Guest







PostPosted: Wed May 27, 2009 9:48 am     Reply with quote

However my basic comment, should be your starting point. One 'main' only. At the moment, nobody looking at your code, could even begin to work out what would actually happen...

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