Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

c code, usb, and at89c5131

Status
Not open for further replies.

nemuri

Newbie level 6
Joined
Apr 6, 2005
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,398
at89c5131 usb

hello,
i'm trying to understand how the at89c5131 usb controller works.
I've downloaded the c code examples at atmel site, but there is something i don't get : where are implemented the functions like usb_read_byte, Usb_clear_rx, usb_rx_complete.... ?
I can see they are used a lot, i know what they do, but i can't find them in extenso.

Thank you
 

at89c5131 usb code

nemuri said:
where are implemented the functions like usb_read_byte, Usb_clear_rx, usb_rx_complete.... ?
I can see they are used a lot, i know what they do, but i can't find them in extenso.
Those are not functions. Are macros. You can get them from usb_drv.h header file

Code:
#define Usb_read_byte ( )       ( UEPDATX )

UEPDATX (USB Endpoint X FIFO Data) it's a SFR register at CFh

To read data from an endpoint, select the correct endpoint number in UEPNUM and
read the UEPDATX register. This action automatically decreases the corresponding
address vector, and the next data is then available in the UEPDATX register.

That's exactly what function bellow is doing:

Code:
Uchar* usb_read_packet (Uchar ep_num, Uchar* rbuf, Uchar data_length)
{
Uchar i;

  Usb_select_ep(ep_num);

  for (i = data_length; i != 0 ; i--, rbuf++) 
     { *rbuf = Usb_read_byte(); } // you can write this as *rbuf = UEPDATX;

  return rbuf;
}

Code:
#define Usb_clear_rx ()  ( UEPSTAX &= ~MSK_RXOUT )
#define Usb_rx_complete ()     ( UEPSTAX & MSK_RXOUTB0B1 )


UEPSTAX (USB Endpoint X Status) it's a SFR register at CEh

Code:
#define MSK_RXOUT     0x02
#define MSK_RXOUTB0B1 0x42  // more on ext_5131.h header file

Read more about UEPSTAX register and meanings of his bits on AT89C5131 data sheet, pag 138 of 175 (doc4136.pdf Atmel site)
 

    nemuri

    Points: 2
    Helpful Answer Positive Rating
at89c5131 usb c

hello all!

> i have been going through the same problem....regarding USB CODE for AT89C5131A-L.

> I have established communication between PC and USB. I can read MY microcontrilller's PID no.

>what i need is to tackle/monitor microcontrolller's port pins through my code.
but for that i need USB module to send my data to microcontroller's port.

> can u people help me out sending the USB MODULE or AT89C5131A-L code.

>or otherwise guide me to a proper way to the solution of the problem.

thankyou all!

i m waiting!!!!!!!!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top