Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
mojtaba_led
PostPosted: Oct 18, 2011 - 06:03 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

Quote:

Look how I have checked this:
http://www.youtube.com/watch?v=oHvL1u1uOvY

excuse me youtube is filter in my country!
can you uplod you'r movie on 4shared or another server?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Oct 18, 2011 - 06:03 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62959
Location: (using avr-gcc in) Finchingfield, Essex, England

On Windows you will find usbdeview.exe to by invaluable I think - it's a free download - it tells you loads about the enumeration of USB devices you plug into the PC. Google it.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
isouxer
PostPosted: Oct 18, 2011 - 06:31 PM
Rookie


Joined: Mar 16, 2011
Posts: 22


clawson wrote:
On Windows you will find usbdeview.exe to by invaluable I think - it's a free download - it tells you loads about the enumeration of USB devices you plug into the PC. Google it.

This is the best solution for you mojtaba_led, as clawson has already said!

and I put a file on site 4shared:
http://www.4shared.com/video/SnGA6Pks/A ... _LUFA.html
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Oct 18, 2011 - 06:54 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

thanks
i download usbdeview.exe and use but i don't see any expect connection than clicck on start application!
my schematic is correct that i use to connect to usb port of pc?
 
 View user's profile Send private message  
Reply with quote Back to top
isouxer
PostPosted: Oct 18, 2011 - 07:24 PM
Rookie


Joined: Mar 16, 2011
Posts: 22


Now you know where to look for the problem. I went through this problem and he was on my board...

Whether you're after build successfully programmed device?
Did you put the VirtualSerial.hex file into device by programmer?
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Oct 18, 2011 - 07:38 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

Quote:

Whether you're after build successfully programmed device?

yes,i sure
this is output then compile :
Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
Quote:

Did you put the VirtualSerial.hex file into device by programmer?

yes,i program flash with flip .

and a question , when run aplication what things display on terminal ?
consider i send "mojtaba" to terminal which function i shoud use that to send it?
and what is you'r terminal that use on that movie ?

thanks
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Oct 18, 2011 - 07:42 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62959
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

yes,i program flash with flip .

The very fact that Flip (and therefore DFU) work shows that the electronics of the USB interface to the PC are setup correctly. (unless you are holding it in bootloader mode all the time with HWB or something?)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Oct 18, 2011 - 08:03 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

Quote:

The very fact that Flip (and therefore DFU) work shows that the electronics of the USB interface to the PC are setup correctly. (unless you are holding it in bootloader mode all the time with HWB or something?)

before i use flip to program my codes to this device and those work corectly
my metod that use is as follow :
1.hold reset then
2.hold hwb then
3.release hwb then
4.release reset then
5.open usb in flip then
6.program flash then
7.click on start application
finish

see i just compile only this cod without any change and excess code ! do i need to add any code ?

Code:


#include "VirtualSerial.h"

/** LUFA CDC Class driver interface configuration and state information. This structure is
 *  passed to all CDC Class driver functions, so that multiple instances of the same class
 *  within a device can be differentiated from one another.
 */
USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
   {
      .Config =
         {
            .ControlInterfaceNumber         = 0,

            .DataINEndpointNumber           = CDC_TX_EPNUM,
            .DataINEndpointSize             = CDC_TXRX_EPSIZE,
            .DataINEndpointDoubleBank       = false,

            .DataOUTEndpointNumber          = CDC_RX_EPNUM,
            .DataOUTEndpointSize            = CDC_TXRX_EPSIZE,
            .DataOUTEndpointDoubleBank      = false,

            .NotificationEndpointNumber     = CDC_NOTIFICATION_EPNUM,
            .NotificationEndpointSize       = CDC_NOTIFICATION_EPSIZE,
            .NotificationEndpointDoubleBank = false,
         },
   };

/** Standard file stream for the CDC interface when set up, so that the virtual CDC COM port can be
 *  used like any regular character stream in the C APIs
 */
static FILE USBSerialStream;


/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
   SetupHardware();

   /* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
   CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);

   LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
   sei();

   for (;;)
   {
      CheckJoystickMovement();

      /* Must throw away unused bytes from the host, or it will lock up while waiting for the device */
      CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);

      CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
      USB_USBTask();
   }
}

/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
   /* Disable watchdog if enabled by bootloader/fuses */
   MCUSR &= ~(1 << WDRF);
   wdt_disable();

   /* Disable clock division */
   clock_prescale_set(clock_div_1);

   /* Hardware Initialization */
   Joystick_Init();
   LEDs_Init();
   USB_Init();
}

/** Checks for changes in the position of the board joystick, sending strings to the host upon each change. */
void CheckJoystickMovement(void)
{
   uint8_t     JoyStatus_LCL = Joystick_GetStatus();
   char*       ReportString  = NULL;
   static bool ActionSent    = false;

   if (JoyStatus_LCL & JOY_UP)
     ReportString = "Joystick Up\r\n";
   else if (JoyStatus_LCL & JOY_DOWN)
     ReportString = "Joystick Down\r\n";
   else if (JoyStatus_LCL & JOY_LEFT)
     ReportString = "Joystick Left\r\n";
   else if (JoyStatus_LCL & JOY_RIGHT)
     ReportString = "Joystick Right\r\n";
   else if (JoyStatus_LCL & JOY_PRESS)
     ReportString = "Joystick Pressed\r\n";
   else
     ActionSent = false;

   if ((ReportString != NULL) && (ActionSent == false))
   {
      ActionSent = true;

      /* Write the string to the virtual COM port via the created character stream */
      fputs(ReportString, &USBSerialStream);

      /* Alternatively, without the stream: */
      // CDC_Device_SendString(&VirtualSerial_CDC_Interface, ReportString);
   }
}

/** Event handler for the library USB Connection event. */
void EVENT_USB_Device_Connect(void)
{
   LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
}

/** Event handler for the library USB Disconnection event. */
void EVENT_USB_Device_Disconnect(void)
{
   LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
}

/** Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
{
   bool ConfigSuccess = true;

   ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface);

   LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
}

/** Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
{
   CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface);
}



thanks
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Oct 19, 2011 - 12:10 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

hi
i can connect to usb and hyperterminal with atmel example for CDC
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Mar 14, 2012 - 04:32 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

hi
i use the VirtualSerial demo to connect to avr (at90usb162) through usb port .
i change the target on makefile to at90usb162 then make all in winavr and it build succefull the .hex then i program that the hex file by flip on micro then perss the application start on flip then pc detect device as "lufa cdc demo" then i instal it's driver from this address: J:\sampels1\winavr\LUFA\LUFA-111009\Demos\Device\ClassDriver\VirtualSerial
and this driver install succefull with Communications Port name.

but now i can't connect to device by any terminal !

please hlep me for this problem

thanks
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Mar 14, 2012 - 04:38 PM
Moderator


Joined: Jan 23, 2004
Posts: 9895
Location: Trondheim, Norway

That version of LUFA contains a CDC bug that causes the problem you are having - update to the newest (corrected) release and recompile.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
mojtaba_led
PostPosted: Mar 14, 2012 - 07:12 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

hi dear dean
thank you

i now download the LUFA-120219 version and make all .
i can to connect with terminal
but
now i want to print a sentence for example i want to display "HELLO WORLD" on terminal to this work , i execes this code in part of progarm of main file :
Code:

int main(void)
{   
   fputs("HELLO WORLD"\r\n", &USBSerialStream);
         
         
         
   SetupHardware();

   /* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
   CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);

   LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
   sei();

   for (;;)
   {
      CheckJoystickMovement();

      /* Must throw away unused bytes from the host, or it will lock up while waiting for the device */
      CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);

      CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
      USB_USBTask();
   }
}

/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
   /* Disable watchdog if enabled by bootloader/fuses */
   MCUSR &= ~(1 << WDRF);
   wdt_disable();

   /* Disable clock division */
   clock_prescale_set(clock_div_1);

   /* Hardware Initialization */
   Joystick_Init();
   LEDs_Init();
   USB_Init();
}


then againe try make all and the hex file builded then i program with flip and start but now don't display anything on terminal !?

please say to me what i do to dispaly and resive a character than devise through writting ion terminal !

thanks
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Mar 14, 2012 - 07:22 PM
Moderator


Joined: Jan 23, 2004
Posts: 9895
Location: Trondheim, Norway

You can't call fputs() before SetupHardware(), or you'll try to write to the USB interface before the USB controller has been initialized. Try placing it just before the main loop.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
mojtaba_led
PostPosted: Mar 14, 2012 - 07:37 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

thanks alot

now, can you say to me for send data for example a character to the avr through trminal what i do !?
or this better, i say for get data with avr from pc which function to use ?
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Mar 14, 2012 - 08:39 PM
Moderator


Joined: Jan 23, 2004
Posts: 9895
Location: Trondheim, Norway

See:

http://www.fourwalledcubicle.com/files/ ... evice.html

Specifically, you can either use the fgetc() function to get a byte of data from the PC, or you can use the functions listed there to read bytes.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
mojtaba_led
PostPosted: Apr 15, 2012 - 09:23 AM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

hi Dean.

i can't send a digit or character from pc to uc !?

i use follow routin for recive data from pc :
Code:

int16_t temp;
char      ReportString2[1];
.
.
.

back:
      USB_USBTask();
   temp = CDC_Device_ReceiveByte (&VirtualSerial_CDC_Interface);
   if(temp<0) goto back;
   itoa(temp,ReportString2,10);   
   
   fputs("\n\r", &USBSerialStream);
   fputs(ReportString2, &USBSerialStream);

this code recive data but send asci code in dec to pc where i want to send digit or charater from pc to pc with uc interface.

can you write an example about recive characther and digit from pc?

thanks
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Apr 15, 2012 - 08:43 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

HI

i can transfer character form pc to pc with follow routin:
Code:

//recive_data_function
recive_data_function(){
int ch;
char str[20];

/*recive data form pc then
send to pc(display on hyper terminal):*/
ch=getc(&USBSerialStream);
while(ch!=EOF){
putc(ch,&USBSerialStream);
fputs("\n\r", &USBSerialStream);
ch=getc(&USBSerialStream);
}

}//recive_data_function


but , the rate of transmit data in above routin is very bad! for example , i must wait to eof check always so when i don't enter a character the routin don't implement so pc lose my charcter !

can tell me a metode to solve this problem?

thanks
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Apr 17, 2012 - 10:39 AM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

hi again!
Mr.Camera

what is you'r intent than this follow parsmeter in Config structure?



Code:

uint8_t  NotificationEndpointNumber;
uint16_t NotificationEndpointSize; 
bool     NotificationEndpointDoubleBank;


i don't understand that what is notification endpoint!?


Please help me.

Thanks
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Apr 17, 2012 - 04:11 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

and again, Hi Mr.Camera!

in this part of you'r web tutorial saied, the USB_Init function have two input as blow:
Code:


void USB_Init (const uint8_t Mode, const uint8_t Options)



but, in VirtualSerial demo ,used this function without any input,as this blow routin :
Code:

void SetupHardware(void)
{
   /* Disable watchdog if enabled by bootloader/fuses */
   MCUSR &= ~(1 << WDRF);
   wdt_disable();

   /* Disable clock division */
   clock_prescale_set(clock_div_1);

   /* Hardware Initialization */
   Joystick_Init();
   LEDs_Init();
   [u][b]USB_Init();[/b][/u]


}


why? what is default input?

thanks again and again!
 
 View user's profile Send private message  
Reply with quote Back to top
mojtaba_led
PostPosted: Apr 17, 2012 - 06:41 PM
Wannabe


Joined: Jun 25, 2011
Posts: 55
Location: IRAN

hi
i find out an other thing!

when i delete this blow function from main routin ,
Code:

CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);


Is increased the speed of routin implementation !

do we have to use this function in main routin or when we want send or recive data Through usb, for corecte opration ?


please help me!
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits