|
|
View previous topic :: View next topic |
Author |
Message |
khwoo
Joined: 26 May 2009 Posts: 12
|
Urgent!! facing problem PIC 18f2550 |
Posted: Tue May 26, 2009 2:13 am |
|
|
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
|
|
Posted: Tue May 26, 2009 8:39 am |
|
|
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
|
|
Posted: Tue May 26, 2009 7:08 pm |
|
|
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
|
|
Posted: Tue May 26, 2009 7:53 pm |
|
|
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
|
|
Posted: Wed May 27, 2009 4:49 am |
|
|
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. |
|
|
Ttelmah Guest
|
|
Posted: Wed May 27, 2009 9:48 am |
|
|
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 |
|
|
|
|
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
|