18F setup

Not rated 10,324

Circuit Image

The PIC18F4550 chip features more capabilities than the PIC16F, including a USB communications module, which adds some complexity. The first consideration is which chip to order. The PICSTART Plus programmer is compatible with the 40-pin PIC18F4550-I/P chip. Variants of the PIC18F4550 include the PIC18LF4550-I/P and the PIC18F4550-I/ML, which may not work with the PICSTART Plus. The PIC18F4550-I/P is available under part number 74K8623. For those who do not prefer assembly language, a compiler is necessary. The company mikroElektronika offers compilers and hardware for PIC development. The book "Advanced PIC Microcontroller Projects in C" includes a limited 2K version of the MikroC Compiler. The capabilities of this 2K version on a PIC are uncertain. Open-source alternatives exist, including a project called SDCC available on SourceForge, which has resources for programming PICs in Linux using C. Microchip also provides a student/demo version of the MPLAB C Compiler for PIC18 microcontrollers, which, after 60 days, disables some optimizations and support for extended instructions. This compiler has been used for learning about these chips. After installing the MPLAB C Compiler, additional files must be downloaded from Microchip, including the USB Framework: Microchip MCHPFSUSB v2.1 Installer.zip, which offers an API for USB communications. Example projects are available for demo boards. The oscillator configurations are detailed in Section 2 of the datasheet. While the PIC16F84A has four oscillator configurations, the PIC18F4550 offers twelve. Careful consideration of configuration parameters is essential when using the USB module, and sections 2.0 through 2.3 of the datasheet, along with figure 2-1, should be reviewed thoroughly. A helpful list of pragma config statements is available from discussion threads. A key restriction is the requirement for a 4 MHz input for the Phase Locked Loop (PLL) circuit, with the PLLDIV value providing eight methods to achieve this frequency by dividing the crystal frequency. The PLL can be bypassed by selecting oscillator frequency modes (FOSC) of XT, HS, EC, or ECIO. The HSPLL, XTPLL, ECPLL, and ECPIO modes necessitate the use of the PLL circuit. In the code, the statement #pragma config FOSC=HSPLL_HS indicates the intention to enable the PLL circuit. A 20 MHz crystal was utilized, and to generate the required 4 MHz for the PLL, PLLDIV=5 was selected, resulting in 20/5=4 MHz. The 96 MHz signal is then divided by two to produce a 48 MHz signal, with the statement #pragma config USBDIV=2 indicating that the USB clock should utilize this 48 MHz signal. In HSPLL mode, the 96 MHz signal is also fed into a CPUDIV module, which can be configured to divide the signal by factors of 2, 3, 4, or 6, corresponding to PLL2, PLL3, PLL4, and PLL6, respectively. In HS mode (bypassing the PLL), another CPUDIV module receives input from the crystal oscillator (OSC) and can divide the frequency by 1, 2, 3, or 4, corresponding to OSC1, OSC2, OSC3, and OSC4. An update from a colleague in Australia indicated difficulties with the example until the USB case or shield wire was connected to ground.

The PIC18F4550 microcontroller is a versatile device suitable for various applications, particularly those requiring USB connectivity. Its enhanced features over the PIC16F series allow for more complex designs. The USB communications module is a significant advantage, enabling the microcontroller to interface with USB devices seamlessly. However, this added functionality necessitates careful planning regarding the oscillator configuration and clock settings.

The oscillator configuration is critical for the performance of the PIC18F4550, especially when utilizing the USB module. The presence of twelve different oscillator configurations provides flexibility, but it also requires meticulous attention to detail in selecting the appropriate settings. The PLL circuit plays a vital role in achieving the necessary clock frequency for USB operations. The choice of crystal frequency and the corresponding PLLDIV setting must align to ensure stable operation.

When programming this microcontroller, selecting an appropriate compiler is essential. The availability of both commercial and open-source compilers allows developers to choose based on their specific needs and preferences. The integration of the USB Framework from Microchip significantly simplifies the process of implementing USB communications, providing a robust API and example projects that can be adapted for various applications.

In summary, the PIC18F4550 microcontroller stands out for its advanced features, particularly the USB module. Proper configuration of the oscillator and clock settings is paramount for optimal performance, and careful selection of development tools will facilitate effective programming and implementation of projects involving this microcontroller.The PIC18F4550 chip contains more features than the PIC16F including a module for USB communications. There is some added complexity. The first issue to resolve is which chip to order. The PICSTART Plus will program the 40 pin PIC18F4550-I/P chip. The PIC18F4550 chip has some variants such as the PIC18LF4550-I/P and the PIC18F4550-I/ML. I don`t think these will work with the PICSTART Plus. The PIC18F4550-I/P is available from as part number 74K8623. Unless you love assembly language, you will need to obtain a compiler. The company mikroElektronika sells compilers and hardware for PIC development. The book Advanced PIC Microcontroller Projects in C includes a 2K limited version of the MikroC Compiler. I`m not sure what you can do with 2K on a PIC. I have not tried this compiler yet. There are open-source alternatives. I will spend more time on these later. There is a project called, SDCC at SourceForge. Here is a link to the article, Programming PICs in Linux using C with SDCC. Microchip provides a student/demo version of the MPLAB C Compiler for PIC18 MCUs. After 60 days of install, some of optimizations and support for extended instructions will be disabled.

This is the compiler I used to learn about these chips. After installing the MPLAB C Compiler, there is some additional files you need to download from Microchip. Microchip provides a USB Framework: Microchip MCHPFSUSB v2. 1 Installer. zip. This framework provides an API for USB communications. The examples provided work with a demo boards. For some reason, I like to do things the hard way. So, I had to build from their examples. Section 2 of the data sheet details the oscillator configurations. Where the PIC16F84A chip had four oscillator configurations, the PIC18F4550 has 12 oscillator configurations.

You must put some thought into the configuration parameters if you are planning to use the USB module. I highly recommend reading sections 2. 0 through 2. 3 (a few times) and study figure 2-1 from the data sheet. Here is a helpful list of pragma config statements that I found on a discussion thread. The first restriction to keep in mind is the 4 MHz input required for the Phase Locked Loop (PLL) circuit.

The PLLDIV value gives you eight different ways to obtain 4 MHz. This is accomplished by dividing the crystal frequency by the value specified in the PLLDIV pragma configuration. You can bypass the PLL completely by choosing the oscillator frequency modes (FOSC) of XT, HS, EC or ECIO.

The HSPLL, XTPLL, ECPLL and ECPIO modes require the PLL circuit. In my code, the statement #pragmaconfigFOSC=HSPLL_HS indicates the desire to enable the PLL circuit. I used a 20 MHz crystal. In order to produce the the 4 MHz need for the PLL, I selected PLLDIV=5. That is, 20/5=4MHz. The 96 MHz signal is divided by two to produce a 48 MHz signal. The statement #pragmaconfigUSBDIV=2 indicates that the USB clock should use this 48 MHz signal. In HSPLL mode, the 96 MHz signal is also passed to a CPUDIV module that can be configured to divide the signal by 2, 3, 4 or 6. These correspond respectively to PLL2, PLL3, PLL4 and PLL6. In HS mode (bypassing PLL), another CPUDIV module would receive input from the crystal oscillator (OSC).

This CPUDIV module can divide the frequency by 1, 2, 3 or 4. These correspond respectively to OSC1, OSC2, OSC3 and OSC4. UPDATE: I received a message from a friend in Australia who tried this example. He had trouble getting it to work until he connected the USB case or shield wire to ground. 🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713