Discussion in "8051 Discussion Forum" started by    Ngel    Jan 15, 2008.
Tue Jan 15 2008, 03:58 am
#1
Hi there, i'm using the atmel at81c5131 mcu with usb interface.
i got "c5131_usb_generic" project and changed a little bit so i will be able to play with it a little bit.
well, i have changed the LENGTH_OF_REPORT to 2 (was 0x20=32), and the user application so i will see waht i sending at the lcd.
the code at the user_application (withput the lcd functions)
void user_application_task (void)
{
  static bit send = 0;
  static char sent = 1;
  int size;
  if(Is_new_data_read())
  {
    size = usb_read_continuous(data_received);
	wrt_char(size, 1, 1);
	wrt_char(data_received[0], 4, 1);
	wrt_char(data_received[1], 8, 1);
	wrt_char(data_received[1], 13, 1);
   	if(data_received[0]==0xe5)
   	{
		send=1;
		LCD_printxy(1,1,"got e5 and send ");
   	}
   	control_LCD(ON,NOBLINK,HIDE);
 	}
	if ((send==1))
    {
       if (Is_write_data_ready())
       {
	   	  LCD_printxy(1,1,"send            ");
          data_to_send[0] = 0x32;
          usb_write_continuous(data_to_send, 1);
		  send=0;
       }
    }
    if (reset_to_bootloader == TRUE)
    {
       Usb_detach();
       Enable_ale();
       for (data_received[0]=0; data_received[0]<250; data_received[0]++);
       Usb_disable();
       Pll_stop();
       EA = 0;
       MAP_BOOT;
       __API_JMP_BOOTLOADER();
	   LCD_printxy(1,1,"usb disabled    ");
    


i connected it to the [blockquote]computer, installed and created the inf file with WinDrive and sent some data with two bits.
when i'm sending at the first time "01h 02h" i'm getting at the screen 02 01 02, but when i send at the second time the same code, i'm geting 02 xx xx (xx= random number).

i cant find the source of the problam here :mad
if any one have an idea or other code i will love to try it.

btw - grate site!
Wed Jan 16 2008, 02:01 pm
#2
i found the problam!
i added one hell of an delay after the size = usb_read_continuous...
and whats happen is that the lcd shows the real numbers i send with windrive but then it get another numbers (that i didnt send).
strange :S
why is that?
Wed Jan 16 2008, 02:13 pm
#3
I am new to USB, I just bought new USB ICs PIC microcontroller to work on USB. I might need your help you.. writing device drivers etc..
what is Windrive by the way?
Wed Jan 16 2008, 02:32 pm
#4
i wiil be happy to help you out
well, windrive drivewizard is a software that can start comunication between the pc to the hardware.
i'm using version 9.
after you install it, you can try something. get an any usb device (that you really do not need, or the mcu) connect it and go to drivewizard click file->new project device search for the device you connected and click "generate inf file", generate the file and save it at your desktop. after that you will need to install the inf by right click on it and select "install". then return to drive wizard and select the device and click "next" now you can see all the "pipes" like contrl pipe and data in and out and how many bytes you can send by one frame. and you can listen to pipe or to send data to pipe and even generte vb or c# program

well, it's all what i can do, i dont have any tryouts with PIC's
but i can send here my usb project for at89c5131 if you will like to
Wed Jan 16 2008, 06:18 pm
#5
how bout this.. once you finish with testing your USB.. then we shift the PC control project to USB?
Like instead of sending data to serial window.. we can send data to USB.. we can use the same program which is already there.. just with small changes we can replace the Serial routine with USB send routine.. tell me if that is feasible.
Can you program USB in asm or only C? even C is not a problem but still want to know coz PC control project is in asm so asm is preferred
Wed Jan 16 2008, 08:42 pm
#6
i think i can make it in c but i need more info about the pc control.
asm will not be good cuz it's too much to program
Wed Jan 16 2008, 10:15 pm
#7
ok...
all i need is to replace the uart sending and receiving routines with USB tx and rx routines. now.. is it possible to send and receive one character via USB? just one character..
Wed Jan 16 2008, 11:58 pm
#8
usb is very complex, you need to start enumaration, ack frames and more.
i sugest to use two mcu, one is an usb mcu that convert usb to rs232 and the second is your project
Thu Jan 17 2008, 09:25 am
#9
no that will only increase the board size..
actually in your test code.. you were sending only two numbers.. 01h 02h
so i thought if sending just two or 3 is possible then would be great.. and of course the USB frame headers and stuff will come the final application will only get the data frame. coz USB frame header are for physical layer.. isn't it?
Mon Jan 21 2008, 05:21 pm
#10
it's true, all the information from the frame will be process in the application, and only the data will be saved in data_received.
well, i found a way to "fix" it by sending 3 bytes and the first byte need to be 0x33, so the mcu will check if the first byte is 0x33 and only then it will show and use the data that recived.
(only if first byte is 0x33 then the data is valid)

Hm... now i add a wireless transiver\reciver and i'm sending data between two mcu's
pc -> usb -> atmel mcu -> RF module ----AIR---- -> RF module -> atmel mcu -> lcd
and it works with 9 bits so i can send adress and data to double data
next i will add more RF modules for half duplex communications

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

chimichmedic1204
Sun May 05 2024, 11:06 am
Jamiegob
Sun May 05 2024, 10:11 am
Gregoryjed
Sun May 05 2024, 10:02 am
Mariocax
Sun May 05 2024, 08:51 am
WilliamErync
Sun May 05 2024, 02:35 am
Danielnof
Sat May 04 2024, 11:12 pm
oriminna
Sat May 04 2024, 08:28 pm
scaneraNom
Sat May 04 2024, 02:21 am