CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

EX_USB_BOOTLOADER.C
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
art



Joined: 21 May 2015
Posts: 181

View user's profile Send private message

PostPosted: Mon Dec 26, 2016 12:07 am     Reply with quote

Hi PCM,

I've just install v5.015 compiler. Result Build Successful

Memory usage: ROM=19% RAM=23% - 30%.

Maybe my compiler v5.008 have some problem.



Thank you very much for your help.
Very Happy
art



Joined: 21 May 2015
Posts: 181

View user's profile Send private message

PostPosted: Tue Dec 27, 2016 7:44 am     Reply with quote

Hi,
This is my application code which I already add the #include usb_bootloader.h.
What and where should I add FUSES to the EX_USB_BOOTLOADER.C file to make it works ?

Code:


#include <18F4550.h>
#fuses HSPLL,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#include <string.h>
#include <input.c>
#include <stdio.h>
#include <stdlib.h>
#include <usb_cdc.h>
#include usb_bootloader.h

void main(void)
 {
 int8 binary_string[10];
 char c;

   usb_init_cs();
   
         while(TRUE)
                   {
                   usb_task();
                   
                         If(usb_cdc_kbhit())
                            {
                               c=usb_cdc_getc();
                               if (c=='\n')  {putc('\r'); putc('\n');}
                               if (c=='\r')   {putc('\r'); putc('\n');}             

                                    while(true)
                                    {       
                                          printf(usb_cdc_putc,"Enter 8 binary number : \n");
                                          get_string_usb(binary_string,9);

                                          output_D((int8)strtoul(binary_string,0,2));
                                     }
                              }
                   }
  }
Ttelmah



Joined: 11 Mar 2010
Posts: 20059

View user's profile Send private message

PostPosted: Tue Dec 27, 2016 9:54 am     Reply with quote

The best way is as follows:

generate your own ex_usb_common.h file that you include in your project directory. Have this contain:
Code:

#ifndef __EX_USB_COMMON_H__
#define __EX_USB_COMMON_H__

#include <18F4550.h>
#fuses HSPLL,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#define BUTTON_PRESSED() !input(PIN_A4)
#define PIN_USB_SENSE   PIN_B2
//Have these to match _your_ input pins.

#define uart_task()
#define HW_INIT()
#define LED_ON(x)
//assuming you don't want an LED


Then in your application, have:
Code:

#include <18F4550.h>
#fuses none
#use delay(clock=48000000)
#use rs232(baud=9600,UART1, ERRORS)

You should _always_ have 'ERRORS' in the RS232 declaration, when using a hardware UART, unless you are adding code to handle errors, so I have corrected this.

Your application code should not have fuses. The bootloader won't load these, and if they did get loaded and differed from the bootloader ones, they could stop the bootloader from running. It's always better that the application that is being loaded by a bootloader, does not setup fuses...

This way the example will compile using your fuse settings and pins only.
art



Joined: 21 May 2015
Posts: 181

View user's profile Send private message

PostPosted: Tue Dec 27, 2016 5:24 pm     Reply with quote

Hi Ttelmah,

Code:

#define HW_INIT()


Based on the original ex_usb_common.h this line does not include inside. Is it compulsory to include it?

Code:

#define USB_HW_CCS_PIC18F4550     //CCS PIC18F4550 USB Development kit


#ifndef __EX_USB_COMMON_H__
#define __EX_USB_COMMON_H__

#if defined(USB_HW_CCS_PIC18F4550)
   #include <18F4550.h>
   #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
   #use delay(clock=48000000)

   //leds ordered from bottom to top
   #DEFINE LED1 PIN_A5  //green
   #define LED2 PIN_B4  //yellow
   #define LED3 PIN_B5  //red
   #define BUTTON_PRESSED() !input(PIN_A4)

   //see section below labeled USB_CABLE_IS_ATTACHED
   #define PIN_USB_SENSE   PIN_B2

   #define HW_ADC_CONFIG   ADC_CLOCK_INTERNAL
   #define HW_ADC_CHANNEL  0
   #define HW_ADC_PORTS    AN0
#endif

Ttelmah



Joined: 11 Mar 2010
Posts: 20059

View user's profile Send private message

PostPosted: Wed Dec 28, 2016 4:16 am     Reply with quote

The 'common' file is designed to setup the hardware for the test application. It sets up a few things that are not needed at all. Typically the bootloader won't use the ADC, so why set it up?. The example bootloader calls 'HW_INIT'. If you want any special setups for your hardware, add them to this, but otherwise it can just do nothing as I show.
art



Joined: 21 May 2015
Posts: 181

View user's profile Send private message

PostPosted: Wed Dec 28, 2016 8:14 am     Reply with quote

Thank you TTelmah for the information.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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