|
|
View previous topic :: View next topic |
Author |
Message |
bsb84 Guest
|
Bootloader files for CCS-PCWH |
Posted: Mon Apr 24, 2006 6:57 am |
|
|
Hi all!
i'm new to this forum and would really appriciate if someone could help me out. I am shfting from PIC16F877A to PIC18F4550 for my project in which i need to transfer data to PC using USB.
When i shifted i was able to program the PIC18F4550 through ICD-U40 and CCS-PCWH compiler, but could'nt get the USB to function. As I am novice in this field, i hear that a bootloader needs to be writen on the PIC and then a driver is needed to be installed for PICs' usb features to work.
So far i have found bootloaders which use MPLAB and ICD2 but i dont have an ICD2 as i am using ICD-U40. When i try to open the Bootloader made for MPLAB in CCS-PCWH compiler i am unable to compile as there are many errors.
Kindly help me out where can i find a bootloader file which i can use in CCS-PCWH and transfer the hex file using ICD-U40. |
|
|
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
Posted: Mon Apr 24, 2006 7:18 am |
|
|
You do not need a bootloader for the PIC's USB functions to to work.
And you may or may not need a driver depending on what you are trying to do. If you simply want to transfer data to the PC, you can simply use Hyperterminal and use the CDC device class, which is basically a modem transfer. Windows has the drivers for this built right in, and the CCS C code is pretty much the same as what you'd write for an RS232 transfer. |
|
|
bsb84 Guest
|
|
Posted: Mon Apr 24, 2006 10:28 am |
|
|
Yes but i want to recieve data using visual basic so is that possible without loadig any firmware into the PIC.
And i am unable to send any data using the normal USB routines.
are there any header files that i am missing ....
my code in CCS goes like this
----------------------------------------------------------------------------
#include <18F4550.h>
#device ICD=TRUE
#device *=16
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#define USB_HID_DEVICE TRUE
#define USB_RUN_WHEN_CONFIGURED TRUE
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT
#define USB_EP1_TX_SIZE 2
#define USB_EP1_RX_ENABLE USB_ENABLE_INTERRUPT
#define USB_EP1_RX_SIZE 2
#include <usb_desc_hid.h>
#include <usbn960x.c>
#include <usb.c>
void main()
{
int8 outdata[USB_EP1_TX_SIZE];
int8 indata[USB_EP1_RX_SIZE];
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(ALL_ANALOG);
usb_init();
delay_ms(1000);
usb_wait_for_enumeration();
while(usb_enumerated())
{
#IF USB_RUN_WHEN_CONFIGURED
set_adc_channel(0); // Acceleration X
delay_us(100);
outdata[0]=read_adc();
set_adc_channel(1); // Acceleration Y
delay_us(100);
outdata[1]=read_adc();
if(usb_put_packet(1,outdata,USB_EP1_TX_SIZE,USB_DTS_TOGGLE))
{
delay_ms(10);
}
#ENDIF
}
} |
|
|
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
Posted: Mon Apr 24, 2006 11:11 am |
|
|
Let me preface my response by saying that I'm no USB expert, nor do I have any experience with bootloaders, so I may be missing what you are trying to do here. If so, I apologize.
Quote: | Yes but i want to recieve data using visual basic so is that possible without loadig any firmware into the PIC. |
As far as I understand, the bootloader merely allows you to load a new HEX file into the PIC using a serial port rather than a programmer. I do not think that the method of programming the PIC will affect your ability to receive data on a PC using Visual Basic. The Visual Basic program will reside on the PC in either case.
Quote: | And i am unable to send any data using the normal USB routines. |
How are you attempting to receive the data on the PC now? I noticed from your program that you are using the HID device class. Do you already have a piece of software that you are using?
Because I like things simple, I personally would use the CDC class. When you plug your device into the PC, it will enumerate itself as a new COM port. Then your problem becomes writing (or borrowing) a Visual Basic program to extract data from that COM port and do whatever you want to do with that data. This is a common procedure for which you can get plenty of help via the Web, books or software-literate friends, if you need help at all.
You will need a simple driver from CCS (or Microchip) which you will have to install on the PC, but that is all.
I have done this as part of a proof-of-concept and it worked great. I used Hyperterminal to store data, but later I will write my own software to massage and present the numbers. As I said, I tend to keep things simple and I found this to be the quickest way to get things going for me.
I'd be interested in understanding what method you intend you use.
Rod |
|
|
|
|
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
|