palabra de configuración 18f4550

14
1 PALABRA DE CONFIGURACIÓN 18F4550: 1.00 PLL1 No PLL PreScaler ó Divide By 1 1.00 PLL2 Divide By 2(8MHz oscillator input) 1.00 PLL3 Divide By 3(12MHz oscillator input) 1.00 PLL4 Divide By 4(16MHz oscillator input) 1.00 PLL5 Divide By 5(20MHz oscillator input) 1.00 PLL6 Divide By 6(24MHz oscillator input) 1.00 PLL10 Divide By 10(40MHz oscillator input) 1.00 PLL12 Divide By 12(48MHz oscillator input) 1.03 CPUDIV1 No System Clock Postscaler 1.03 CPUDIV2 System Clock by 2 1.03 CPUDIV3 System Clock by 3 1.03 CPUDIV4 System Clock by 4 1.05 NOUSBDIV USB clock source comes from primary oscillator 1.05 USBDIV USB clock source comes from PLL divide by 2 1.08 XT Crystal osc <= 4MHz for PCM/PCH , 3mhz to 10 MHz for PCD 1.08 XTPLL Crystal/Resonator with PLL enabled 1.08 EC_IO External clock 1.08 EC External clock with CLKOUT 1.08 ECPLL_IO External Clock with PLL enabled, I/O on RA6 1.08 ECPLL External Clock with PLL enabled and Fosc/4 on RA6 1.08 INTRC_IO Internal RC Osc, no CLKOUT 1.08 INTRC Internal RC Osc 1.08 INTXT Internal Oscillator, XT used by USB 1.08 INTHS Internal Oscillator, HS used by USB 1.08 HS High speed Osc (> 4MHz for PCM/PCH) (>10MHz for PCD) 1.08 HSPLL High Speed Crystal/Resonator with PLL enabled 4 MHz 48 MHz

Upload: tito-arispe

Post on 07-Feb-2016

36 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Palabra de Configuración 18f4550

1

PALABRA DE CONFIGURACIÓN 18F4550:

1.00 PLL1 No PLL PreScaler ó Divide By 11.00 PLL2 Divide By 2(8MHz oscillator input)1.00 PLL3 Divide By 3(12MHz oscillator input)1.00 PLL4 Divide By 4(16MHz oscillator input)1.00 PLL5 Divide By 5(20MHz oscillator input)1.00 PLL6 Divide By 6(24MHz oscillator input)1.00 PLL10 Divide By 10(40MHz oscillator input)1.00 PLL12 Divide By 12(48MHz oscillator input)

1.03 CPUDIV1 No System Clock Postscaler1.03 CPUDIV2 System Clock by 21.03 CPUDIV3 System Clock by 31.03 CPUDIV4 System Clock by 4

1.05 NOUSBDIV USB clock source comes from primary oscillator1.05 USBDIV USB clock source comes from PLL divide by 2

1.08 XT Crystal osc <= 4MHz for PCM/PCH , 3mhz to 10 MHz for PCD1.08 XTPLL Crystal/Resonator with PLL enabled1.08 EC_IO External clock1.08 EC External clock with CLKOUT1.08 ECPLL_IO External Clock with PLL enabled, I/O on RA61.08 ECPLL External Clock with PLL enabled and Fosc/4 on RA61.08 INTRC_IO Internal RC Osc, no CLKOUT1.08 INTRC Internal RC Osc1.08 INTXT Internal Oscillator, XT used by USB1.08 INTHS Internal Oscillator, HS used by USB1.08 HS High speed Osc (> 4MHz for PCM/PCH) (>10MHz for PCD)1.08 HSPLL High Speed Crystal/Resonator with PLL enabled

4 MHz

48 MHz

4 MHz

Page 2: Palabra de Configuración 18f4550

2

USDIV: USDIV=1. La señal de reloj pasa por el PLL PrescalerPLL1: PLLDIV=000 (%1). Entrada PLL Prescaler (4 MHz). Salida PLL Prescaler (4MHz)CPUDIV1: CPUDIV=00 (%1). Se mantienen los 4 MHz para temporizar el sistema (CPU)

1.14 NOFCMEN Fail-safe clock monitor disabled1.14 FCMEN Fail-safe clock monitor enabled

1.15 NOIESO Internal External Switch Over mode disabled1.15 IESO Internal External Switch Over mode enabled

2.00 PUT Power Up Timer2.00 NOPUT No Power Up Timer

2.01 NOBROWNOUT No brownout reset2.01 BROWNOUT_SW Brownout controlled by configuration bit in special file register2.01 BROWNOUT_NOSL Brownout enabled during operation, disabled during SLEEP2.01 BROWNOUT Reset when brownout detected

2.03 BORV45 Brownout reset at 4.5V2.03 BORV43 Brownout reset at 4.3V2.03 BORV27 Brownout reset at 2.7V2.03 BORV20 Brownout reset at 2.0V

2.05 NOVREGEN USB voltage regulator disabled2.05 VREGEN USB voltage regulator enabled

2.08 NOWDT No Watch Dog Timer2.08 WDT Watch Dog Timer

2.09 WDT1 Watch Dog Timer uses 1:1 Postscale2.09 WDT2 Watch Dog Timer uses 1:2 Postscale2.09 WDT4 Watch Dog Timer uses 1:4 Postscale2.09 WDT8 Watch Dog Timer uses 1:8 Postscale2.09 WDT16 Watch Dog Timer uses 1:16 Postscale2.09 WDT32 Watch Dog Timer uses 1:32 Postscale2.09 WDT64 Watch Dog Timer uses 1:64 Postscale2.09 WDT128 Watch Dog Timer uses 1:128 Postscale2.09 WDT256 Watch Dog Timer uses 1:256 Postscale2.09 WDT512 Watch Dog Timer uses 1:512 Postscale2.09 WDT1024 Watch Dog Timer uses 1:1024 Postscale2.09 WDT2048 Watch Dog Timer uses 1:2048 Postscale2.09 WDT4096 Watch Dog Timer uses 1:4096 Postscale2.09 WDT8192 Watch Dog Timer uses 1:8192 Postscale2.09 WDT16384 Watch Dog Timer uses 1:16384 Postscale2.09 WDT32768 Watch Dog Timer uses 1:32768 Postscale

Page 3: Palabra de Configuración 18f4550

3

3.08 CCP2B3 CCP2 input/output multiplexed with RB33.08 CCP2C1 CCP2 input/output multiplexed with RC1

3.09 NOPBADEN PORTB pins are configured as digital I/O on RESET3.09 PBADEN PORTB pins are configured as analog input channels on RESET

3.10 NOLPT1OSC Timer1 configured for higher power operation3.10 LPT1OSC Timer1 configured for low-power operation

3.15 NOMCLR Master Clear pin used for I/O3.15 MCLR Master Clear pin enabled

4.00 NOSTVREN Stack full/underflow will not cause reset4.00 STVREN Stack full/underflow will cause reset

4.02 NOLVP No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O4.02 LVP Low Voltage Programming on B3(PIC16) or B5(PIC18)

4.05 ICSP1 ICD uses PGC1/PGD1 pins4.05 ICSP2 ICD uses PGC2/PGD2 pins

4.06 NOXINST Extended set extension and Indexed Addressing mode disabled (Legacy mode)4.06 XINST Extended set extension and Indexed Addressing mode enabled

4.07 DEBUG Debug mode for use with ICD4.07 NODEBUG No Debug mode for ICD

5.00 PROTECT Code protected from reads5.00 NOPROTECT Code not protected from reading

5.14 CPB Boot Block Code Protected5.14 NOCPB No Boot Block code protection

5.15 CPD Data EEPROM Code Protected5.15 NOCPD No EE protection

6.00 WRT Program Memory Write Protected6.00 NOWRT Program memory not write protected

6.13 WRTC Configuration registers write protected6.13 NOWRTC Configuration registers not write protected

6.14 WRTB Boot block write protected6.14 NOWRTB Boot block not write protected

6.15 WRTD Data EEPROM write protected

Page 4: Palabra de Configuración 18f4550

4

6.15 NOWRTD Data EEPROM not write protected

7.00 EBTR Memory protected from table reads7.00 NOEBTR Memory not protected from table reads

7.14 EBTRB Boot block protected from table reads7.14 NOEBTRB Boot block not protected from table reads

PRÁCTICA Nro. 1: Encendido y apagado de un LED en RBO

/*---------------------------------------------------------------------------------------------*//* Ciclo de encendido (1s) y apagado (1s)de un LED conectado en RB0 *//*---------------------------------------------------------------------------------------------*/#include <18F4550.h>#fuses PLL1,CPUDIV1,USBDIV,XT,NOFCMEN,NOIESO,PUT,NOBROWNOUT,NOWDT,CCP2C1#fuses NOPBADEN,NOLPT1OSC,MCLR,STVREN,NOLVP,NOXINST,NODEBUG,NOPROTECT#fuses NOCPB,NOCPD,NOWRT,NOWRTC,NOWRTB,NOWRTD,NOEBTR,NOEBTRB#use delay (clock=4M)

void main() {

Page 5: Palabra de Configuración 18f4550

5

while(TRUE) { output_bit(PIN_B0,1); // Enciende LED en RB0. Tb output_high(PIN_B0) delay_ms(1000); // Retardo de 1000 ms output_bit(PIN_B0,0); // Apaga LED en RB0 delay_ms(1000); // Retardo de 1000 ms }}

PRÁCTICA Nro. 2: Encendido y apagado de un LED en RBO

/*----------------------------------------------------------------------*//* Encendido y apagado de un led en RB2 con *//* pulsadores en RB0 y RB1. *//*----------------------------------------------------------------------*/#include <18F4550.h>#fuses PLL1,CPUDIV1,USBDIV,XT,NOFCMEN,NOIESO,PUT,NOBROWNOUT,NOWDT,CCP2C1#fuses NOPBADEN,NOLPT1OSC,MCLR,STVREN,NOLVP,NOXINST,NODEBUG,NOPROTECT#fuses NOCPB,NOCPD,NOWRT,NOWRTC,NOWRTB,NOWRTD,NOEBTR,NOEBTRB#use delay (clock=4M)

void rebote(){ unsigned int16 j = 0; int1 save, current; save = 0;

Page 6: Palabra de Configuración 18f4550

6

for(j = 0; j < 400; j++) { if((current == input_state(PIN_B0)) != save || (current == input_state(PIN_B1)) != save) j = 0; save = current; }}

void main(){ port_b_pullups (TRUE); output_low(PIN_B2); while(TRUE) { if(!input(PIN_B0)) { rebote(); output_toggle(PIN_B2); } if(!input(PIN_B1)) { rebote(); output_toggle(PIN_B2); } } }

Page 7: Palabra de Configuración 18f4550

7

PRÁCTICA Nro. 3: Conversor A/D

/*--------------------------------------------------------------------------*//* EL RESULTADO DE LA CONVERSIÓN A/D DEL CANAL0 *//* SE MUESTRA EN EL PUERTO B Y PUERTO C *//*--------------------------------------------------------------------------*/#include <18F4550.h>#fuses PLL1,CPUDIV1,USBDIV,XT,NOFCMEN,NOIESO,PUT,NOBROWNOUT,NOWDT,CCP2C1#fuses NOPBADEN,NOLPT1OSC,MCLR,STVREN,NOLVP,NOXINST,NODEBUG,NOPROTECT#fuses NOCPB,NOCPD,NOWRT,NOWRTC,NOWRTB,NOWRTD,NOEBTR,NOEBTRB#device ADC=10#use delay (clock=4M)/*----------------------------------------------------------------------*/void main(){ int16 adcValue; int8 i; setup_adc_ports(AN0); setup_adc(ADC_CLOCK_INTERNAL); do { set_adc_channel(0); delay_us(20); // Retardo para carga del condensador de muestreo adcValue=read_adc(); // Lee el resultado de la conversión output_b(adcValue); // Parte baja de la conversión a PORTB for (i=0;i<8;i++) rotate_right(&adcValue,2); // shift_right(&adcValue,2,1); output_c(adcValue); // Parte alta de la conversión a PORTC

Page 8: Palabra de Configuración 18f4550

8

} while (TRUE);}

PRÁCTICA Nro. 4: Conmutador, usando función rebote()

/*----------------------------------------------------------------------*//* Temperatura actual por canal 0 y LM35 *//* Temperatura a mantener se cambia con RA4 *//*----------------------------------------------------------------------*/#include <18F4550.h>#fuses PLL1,CPUDIV1,USBDIV,XT,NOFCMEN,NOIESO,PUT,NOBROWNOUT,NOWDT,CCP2C1#fuses NOPBADEN,NOLPT1OSC,MCLR,STVREN,NOLVP,NOXINST,NODEBUG,NOPROTECT#fuses NOCPB,NOCPD,NOWRT,NOWRTC,NOWRTB,NOWRTD,NOEBTR,NOEBTRB#device ADC=10#use delay (clock=4M)#include <LCD.C> // Libreria LCD.C sin modificar. LCD en PORTD

#byte TRISA=0xF92 // se define el registro TRISA como byte#byte TRISB=0xF93#bit RA4=0xF80.4#bit RB0=0xF81.0

void rebote(){ unsigned int16 j = 0; int1 save, current; save = 0; for(j = 0; j < 400; j++)

Page 9: Palabra de Configuración 18f4550

9

{ if((current == RA4) != save) j = 0; save = current; }}

void main (){ float res, resaux=0; float data[10]; int nro=9,j,i=0,var=20; lcd_init(); setup_adc(ADC_CLOCK_INTERNAL); setup_adc_ports(AN0); TRISA=0B11111111; TRISB=0B11111110;

while (TRUE) { if(RA4==0) { rebote(); var++; if (var > 35) var=20; } set_adc_channel (0); delay_us(20); // Retardo para carga del condensador de muestreo res = read_adc (); data[i] = 5 * res * 100/1023; i++; if (i==nro) { for (j=0;j<=nro;j++) resaux=resaux+data[j]; resaux=resaux/j; i=0; if(resaux<var) RB0=1; else RB0=0; } lcd_gotoxy(1,1); printf(lcd_putc,"Tactual:"); lcd_gotoxy(11,1); printf(lcd_putc,"Tset:");

Page 10: Palabra de Configuración 18f4550

10

lcd_gotoxy(1,2); printf(lcd_putc,"%4.1f'c"resaux); lcd_gotoxy(10,2); printf(lcd_putc,"%3d'c"var); delay_ms(100); }}

PRÁCTICA Nro. 5: Conmutador, usando función rebote(). Librería LCD.C, sin cambiar. Pines de LCD cambiados en el programa, mediante directivas y antes de la llamada a la librería.

/*----------------------------------------------------------------------*//* Temperatura actual por canal 0 y LM35 *//* Temperatura a mantener se cambia con RA4 *//*----------------------------------------------------------------------*/#include <18F4550.h>#fuses PLL1,CPUDIV1,USBDIV,XT,NOWDT,NOPBADEN,MCLR,NOLVP,NODEBUG,NOPROTECT#fuses NOFCMEN,PUT,NOBROWNOUT,CCP2C1,NOLPT1OSC,STVREN,NOXINST,NOCPB,NOCPD,NOWRT,NOWRTC,NOWRTB,NOWRTD,NOEBTR,NOEBTRB#device ADC=10#use delay (clock=4M)

Page 11: Palabra de Configuración 18f4550

11

#define LCD_ENABLE_PIN PIN_E0 #define LCD_RS_PIN PIN_E1 #define LCD_RW_PIN PIN_E2 #define LCD_DATA4 PIN_C4 #define LCD_DATA5 PIN_C5 #define LCD_DATA6 PIN_C6 #define LCD_DATA7 PIN_C7 #include <LCD.C> // Libreria LCD.C sin modificar. Pines de LCD cambiados

#byte TRISA=0xF92 // se define el registro TRISA como byte#byte TRISB=0xF93#bit RA4=0xF80.4#bit RB0=0xF81.0

void rebote(){ unsigned int16 j = 0; int1 save, current; save = 0; for(j = 0; j < 400; j++) { if((current == RA4) != save) j = 0; save = current; }}

void main (){ float res, resaux=0; float data[10]; int nro=9,j,i=0,var=20; lcd_init(); setup_adc(ADC_CLOCK_INTERNAL); setup_adc_ports(AN0); TRISA=0B11111111; TRISB=0B11111110;

while (TRUE) { if(RA4==0) { rebote(); var++; if (var > 35) var=20; }

Page 12: Palabra de Configuración 18f4550

12

set_adc_channel (0); delay_us(20); // Retardo para carga del condensador de muestreo res = read_adc (); data[i] = 5 * res * 100/1023; i++; if (i==nro) { for (j=0;j<=nro;j++) resaux=resaux+data[j]; resaux=resaux/j; i=0; if(resaux<var) RB0=1; else RB0=0; } lcd_gotoxy(1,1); printf(lcd_putc,"Tactual:"); lcd_gotoxy(11,1); printf(lcd_putc,"Tset:");

lcd_gotoxy(1,2); printf(lcd_putc,"%4.1f'c"resaux); lcd_gotoxy(10,2); printf(lcd_putc,"%3d'c"var); delay_ms(100); }}