Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Usb

Status
Not open for further replies.

AtomSoft

Well-Known Member
As i didnt want to hijack a thread i thought id make another...

My Original Post was:
"Hey i just tried:
**broken link removed**

I got it to work on a 18F2550! I was so excited when it worked lol. Now im off to alter it to my needs."

Im trying to add my lcd to this using 4 bit and the 2 wire trick by futz. The only issue i think im having is determining the speed of the clock. Im using a 20 MHz clock and these are my config bits on a 18F2550:

Code:
#pragma config WDT = OFF, LVP = OFF, PLLDIV = 5, CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2,FOSC = HSPLL_HS

What is the final speed the PIC uses then? Also how would i get this info for future use? Like how do i determine the final speed?
 
It is running at 48MHz and 12MHz instructions. The PLL has to be fed a 4MHz signal and so your 20MHz has to be divided by 5 (PLLDIV=5). This gives a PLL output of 96MHZ. The CPUDIV=OSC1_PLL2 is the 96MHz divided by two = 48MHz.

Mike.
 
thanks. I was having some hard time trying to figure that out.

EDIT: It works! Thanks a Bunch! Now i have to write code to send new data to LCD but thats the fun part lol
 
Last edited:
weird ... it works fine in debug mode but in running it straight the characters on LCD are not correct not even the length of characters. So what im going to do is introduce another pic into the project by communicating VIA USART or ill just make my own protocol.
 
Just wanted to show my board ... dont have my printer yet to make custom PCB so used radioshack as usual.

Here are many Pictures.. and some screen shots...
usbinstall-jpg.23424


RB4:0 have jumpers on them so you can remove some to use for non led purpose...

All usable pins are extruded (has a header) if pin is for use and CANNOT be used like D-/D+ no HEADER is used.
 

Attachments

  • devman.jpg
    devman.jpg
    3.7 KB · Views: 143
  • usbinstall.jpg
    usbinstall.jpg
    31.5 KB · Views: 277
  • Picture 008.jpg
    Picture 008.jpg
    58.2 KB · Views: 149
  • Picture 009.jpg
    Picture 009.jpg
    55.4 KB · Views: 168
  • Picture 010.jpg
    Picture 010.jpg
    36.4 KB · Views: 145
  • Picture 011.jpg
    Picture 011.jpg
    34.2 KB · Views: 145
  • Picture 012.jpg
    Picture 012.jpg
    38.8 KB · Views: 141
  • Picture 013.jpg
    Picture 013.jpg
    37.6 KB · Views: 143
  • Picture 014.jpg
    Picture 014.jpg
    39.5 KB · Views: 141
  • Picture 015.jpg
    Picture 015.jpg
    46.7 KB · Views: 151
Last edited:
Hey i own about 3 PIC18LF2550's and wanted to know how would i go about having this work with USB? Would i simple power the 3.3v Regulator from the 5v USB? What about input data. Does LF have 5v tolerance inputs?

Where can i get information on LF pics? I never seem to find any. Like its a legendary item lol
 
i did thanks...

Now im trying my best to go through this code to find out why my interrupt code is freezing the pic on start-up.

Code:
//This is the User Initialization code
void UserInit(void)
{
    mInitAllLEDs();

	TRISBbits.TRISB4 = 1;                        
	TRISBbits.TRISB5 = 1;

	INTCON3 = 0x00;
	INTCON2 = 0x00;
	INTCON = 0b10001000;



}//end UserInit

Code:
//This is supposed to happen when a interrupt occurs:
#pragma code _LOW_INTERRUPT_VECTOR = 0x000818
void _low_ISR (void)
{

	INTCONbits.TMR0IF = 0;
	INTCONbits.INT0IF = 0;
	INTCONbits.RBIF = 0;
	INTCON3bits.INT2IF = 0;
	INTCON3bits.INT1IF = 0;

	mLED_4_Toggle();

}

But it doesnt even start when i have that code in place.
 
Your clearing the flag (RBIF) but you also have to read from PortB to clear the mismatch before clearing the flag.

Mike.
 
I also have to read PORTB? Ok ill try it... Cross your fingers :)

I was reading about the Microchip MCHPFSUSB v2.2 seems like a nice collection of info.

I got the 18lf2550 working with some changes using "USB Device - HID - Simple Custom Demo" from there. Also learned some C++ 2008 in the process :D

I added another button (now has 2 ) and control over the 2 extra LEDs i have on board.

Heres a screen shot of the app. and a pic of the breadboard.

cppapp-jpg.23481


cppapp2-jpg.23482
 

Attachments

  • cppapp.jpg
    cppapp.jpg
    10.1 KB · Views: 253
  • cppapp2.jpg
    cppapp2.jpg
    76.6 KB · Views: 264
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top