Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: AT91SAM7S CDC strange behaviour
PostPosted: Tue Sep 27, 2011 10:25 am 
Offline

Joined: Tue Aug 30, 2011 7:00 pm
Posts: 1
Hello,
I am working on USB CDC communication with PC using virtual COM port and it works but I dont understand one line of code. I am using usb-device-cdc-serial-project-at91sam7s-ek-keil as template. My code is:
TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK);
// If they are present, configure Vbus & Wake-up pins
PIO_InitializeInterrupts(0);
//Driver initialization
CDCDSerialDriver_Initialize();
//Connect if needed
VBUS_CONFIGURE();
//Loop
while (1) {
CDCDSerialDriver_Write("Ahoj\n\r\0",7, 0, 0);}
This code works and it sends string to terminal, but when i comment first line with TRACE_CONFIGURE, virtual com port is not opened and device is not recognized after connection to PC. Can somebody tell me why is it so? I dont need tracing in my app. (sorry if it is stupid question. I am very new to uControllers)


Top
 Profile  
 
 Post subject: Re: AT91SAM7S CDC strange behaviour
PostPosted: Thu Oct 13, 2011 4:13 pm 
Offline

Joined: Wed Sep 21, 2011 12:46 pm
Posts: 2
Hi, try to make this in the main while :

while (1){
// Device is not configured
if (USBD_GetState() < USBD_STATE_CONFIGURED) {

// Connect pull-up, wait for configuration
USBD_Connect();
while (USBD_GetState() < USBD_STATE_CONFIGURED);
}


if( USBState == STATE_SUSPEND ) {
TRACE_DEBUG("suspend !\n\r");
LowPowerMode();
USBState = STATE_IDLE;
}
if( USBState == STATE_RESUME ) {
// Return in normal MODE
TRACE_DEBUG("resume !\n\r");
NormalPowerMode();
USBState = STATE_IDLE;
}

CDCDSerialDriver_Write("Ahoj\n\r\0",7, 0, 0);
}

Maybe you have to wait till the usb bus is ready.
Regards, Toni.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


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 post attachments in this forum

Search for:
Jump to: