|
|
View previous topic :: View next topic |
Author |
Message |
dileep
Joined: 24 Sep 2013 Posts: 2 Location: ERANAKULAM
|
USB fuse bits in 18F45K50 |
Posted: Tue Sep 24, 2013 10:30 pm |
|
|
Can anybody tell the USB fuse bits in PIC18F45K50 ?
I am using 16MHz crystal ...
I used the fuse bits as follows,
Code: | #fuses NOCPUDIV, PLLEN, PLL3X, HSH, PRIMARY, NOIESO, NOFCMEN
#use delay(clock=48MHz) |
I checked it in hardware. But it didn't work.
Also I can't simulate it in proteus ver 8. The Proteus library does not contain PIC18F45K50.
Is there any different solution to real time simulation!!!! |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Wed Sep 25, 2013 12:47 am |
|
|
I looked it up in CCS IDE, and the fuses I see there for the 45K50 - USB are
LS24MHX
LS48MHZ |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Wed Sep 25, 2013 2:14 am |
|
|
The LS24/LS48 bits are only used for low speed USB. Provided the code is setup to use full speed, the FSEN bit will be set, and these do nothing.
Question obviously is to post the rest of the first few lines of the main code (where you load whatever USB driver you are using).
Have you done a basic 'flash an LED' test, and verified that the CPU is running, and running at the expected rate?. What voltage are you running?. How have you powered Vusb?. Are you using the internal regulator?. You don't have NOMCLR selected, so is the MCLR pin pulled high?. What compiler version?.
Best Wishes |
|
|
dileep
Joined: 24 Sep 2013 Posts: 2 Location: ERANAKULAM
|
USB fuse bits in 18F45K50 |
Posted: Wed Sep 25, 2013 5:24 am |
|
|
Thanks for the valuable replies......
I got the code from google search,
It is for PIC18F4550, and as per the code I downloaded usb HID terminal ver1.0
For PIC18F45K50 I changed the fuse bits...
I changed the crystal to 12MHz ............
It detects my USB device and can send data,
But the Reset function is not working.....
Please help me to correct the fuse bits....
How can i change VID and PID ?
which are the fuse bits to give internal ref volt ?
My compiler version is 5.010
The code is as follows
Code: | #include <18F45K50.h>
#device ADC=8
#fuses NOCPUDIV,PLLEN,PLL4X,HSH,PRIMARY,NOIESO,NOFCMEN //12mhz crystal, 48mhz clock for pic and usb
#use delay(clock=48MHz)
//////#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN////////////
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include "term.c"
#define LED1 PIN_B4
#define LED2 PIN_B6
#define LED3 PIN_B5
//Transmit and Receive Packet Size
#define USB_CONFIG_HID_TX_SIZE 1
#define USB_CONFIG_HID_RX_SIZE 8
/*******VENDOR ID AND PRODUCT ID********/
#define USB_CONFIG_PID 0001 //Chnage Vendor Id and Product Id
#define USB_CONFIG_VID 4660 //So that they will work with my Application
/***************************************/
/*******LCD Pin Configuration******/
#define LCD_ENABLE_PIN PIN_E2
#define LCD_RS_PIN PIN_E0
#define LCD_RW_PIN PIN_E1
#define LCD_DATA4 PIN_A1
#define LCD_DATA5 PIN_A2
#define LCD_DATA6 PIN_A3
#define LCD_DATA7 PIN_A5
/***********************************/
#include<pic18_usb.h>
#include<usb_desc_hid.h>
#include<usb.c>
#include<lcd.c>
//#include "USBdsc.c"
//Macro Definition for LED ON and OFF
#define LED_ON(x) output_low(x)
#define LED_OFF(x) output_high(x)
void usb_debug_task(void)
{
static int8 last_connected;
static int8 last_enumerated;
int8 new_connected;
int8 new_enumerated;
new_connected = usb_attached();
new_enumerated = usb_enumerated();
if (new_enumerated)
LED_ON(LED1);
else
LED_OFF(LED1);
if (new_connected && !last_connected)
printf("\r\n\nUSB connected, waiting for enumaration...");
if (!new_connected && last_connected)
printf("\r\n\nUSB disconnected, waiting for connection...");
if (new_enumerated && !last_enumerated)
printf("\r\n\nUSB enumerated by PC/HOST");
if (!new_enumerated && last_enumerated)
printf("\r\n\nUSB unenumerated by PC/HOST, waiting for enumeration...");
last_connected=new_connected;
last_enumerated=new_enumerated;
}
void main(void)
{
unsigned char in_data[8];
// unsigned char c[6]="hello";
unsigned char table[40]="Hello how are you";
unsigned int i,s;
lcd_init();
lcd_putc("\fWELCOME");
usb_init_cs();
while(1)
{
usb_task();
usb_debug_task();
if(usb_enumerated())
{
if(usb_kbhit(1))
{
lcd_gotoxy(1,2);
lcd_putc(" ");
usb_get_packet(1,in_data,8);
printf("\r\nReceived Data: ");
for(i=0;table[i];i++)
{
usb_put_packet(1,&table[i],1,USB_DTS_TOGGLE);
delay_ms(10);
}
for(i=0;in_data[i];i++)
{
printf("%c",in_data[i]);
//Send the Recevied Data to Serial Port
lcd_gotoxy(1+i,2);
lcd_putc(in_data[i]);
}
for(i=0;i<8;i++)
{
in_data[i] = '\0';
}
}
}
}
}
|
Thanks..... |
|
|
DARS_23
Joined: 31 Oct 2015 Posts: 1
|
|
Posted: Sat Oct 31, 2015 3:32 pm |
|
|
You must use #fuses MCLR
and for 12Mhz crystal need #fuses PLL3X //instead pll4x see datasheet oscillator modes |
|
|
|
|
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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|