Autor Tema: Ejemplos PIC18F4550  (Leído 80409 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado sander

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 624
Re: Ejemplos PIC18F4550
« Respuesta #15 en: 12 de Octubre de 2008, 12:10:50 »
Saludos Leon Pic, Me parece muy buena tu idea de organizar tus rutinas , yo voy hacer lo propio con las rutinas que voy escribiendo para este PIC tratando de hacerlas lo mas generales posibles. se me esta ocurriendo que talvez el ultimo ejemplo podria ser el uso de las rutinas que  voy escribiendo usando el MPLINK, como si de librerias se trataran, pero en realidad para ese ultimo ejemplo falta muucho todavia, hay varias cosas que quiero probar antes.

La electrónica es el arte de manipular señales eléctricas que transportan información
Jan Davidse

Visita mi blog
Visita mi canal de youtube

Desconectado Leon Pic

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3610
    • Impresiones en 3D
Re: Ejemplos PIC18F4550
« Respuesta #16 en: 16 de Noviembre de 2008, 14:46:29 »
Jesús dijo, yo soy el CAMINO, la VERDAD y la VIDA, nadie llega al PADRE si no es por mi.

Desconectado epacho1

  • PIC10
  • *
  • Mensajes: 10
Re: Ejemplos PIC18F4550
« Respuesta #17 en: 14 de Enero de 2009, 13:33:59 »
Felicitaciones a tu aporte, me parece excelente que programes en ASSEMBLER, yo programo en C y en Basic tambien, pero creo que en asm tu aprendes el funcionamiento del uC muy a fondo ya que tienens que configurarlo por completo para que funcione. Me gustaria saber si ya has creado un programa para USB pero en asm???

Saludos

Desconectado LABmouse

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 3575
    • Juntos es mejor
Re: Ejemplos PIC18F4550
« Respuesta #18 en: 15 de Mayo de 2009, 23:58:34 »
sander,
Quiero agradecerte por colocar estos códigos en ASM tan pero tan bien explicados.. Te felicito por ser tan organizado.

SALUDOS!

Desconectado silcarmig

  • PIC10
  • *
  • Mensajes: 1
Re: Ejemplos PIC18F4550
« Respuesta #19 en: 19 de Junio de 2010, 17:42:51 »
GRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACIAS

Desconectado cosmic

  • PIC16
  • ***
  • Mensajes: 175
Re: Ejemplos PIC18F4550
« Respuesta #20 en: 21 de Noviembre de 2010, 16:37:13 »
Amigo sander como estas? :)
Gracias por los ejemplos
Tienes un ejemplo de conversion AD con este pic.. :-/
Gracias de nuevo y hasta pronto.
« Última modificación: 21 de Noviembre de 2010, 16:40:43 por wilrey »

Desconectado c@Lic_0

  • PIC10
  • *
  • Mensajes: 36
    • Una tasita de cafe
Re: Ejemplos PIC18F4550
« Respuesta #21 en: 24 de Enero de 2011, 22:31:52 »
felicidades por el trabajo que realizas, por ahi me entro una 'dudilla', cuando reservas memoria para:
      CBLOCK   0x080       
                                     WREG_TEMP      ;variable usada para salvar contexto       
                                     STATUS_TEMP      ;variable usada para salvar contexto       
                                     BSR_TEMP      ;variable usada para salvar contexto       
                                ENDC
es la que usas para salvar contexto cuando llega la interrupcion, estos registros no se guardan de manera automatica cuando llega la interrupcion en los pic18?¡?¡?

Desconectado sander

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 624
Re: Ejemplos PIC18F4550
« Respuesta #22 en: 25 de Enero de 2011, 11:53:57 »
felicidades por el trabajo que realizas, por ahi me entro una 'dudilla', cuando reservas memoria para:
      CBLOCK   0x080       
                                     WREG_TEMP      ;variable usada para salvar contexto       
                                     STATUS_TEMP      ;variable usada para salvar contexto       
                                     BSR_TEMP      ;variable usada para salvar contexto       
                                ENDC
es la que usas para salvar contexto cuando llega la interrupcion, estos registros no se guardan de manera automatica cuando llega la interrupcion en los pic18?¡?¡?

Hola c@lic_0,  los registros se guardan de manera automatica cuando, se salta al vector de interrupcion 0x0008 (el de alta prioridad o de modo compatible), pero si vas a usar interrupciones de baja prioridad(direccion 0x0018) necesitas guardar estos registros, ya que estos no se guardan solos.

Saludos
La electrónica es el arte de manipular señales eléctricas que transportan información
Jan Davidse

Visita mi blog
Visita mi canal de youtube

Desconectado c@Lic_0

  • PIC10
  • *
  • Mensajes: 36
    • Una tasita de cafe
Re: Ejemplos PIC18F4550
« Respuesta #23 en: 09 de Febrero de 2011, 13:14:47 »

;******************************************************************************



   LIST P=18F4550      ;Directiva para definir el procesador

   #include <P18F4550.INC>   ;Definicion de SFRs para el procesador



;******************************************************************************

;Bits de Configuracion

;Microchip ha cambiado el formato para definir los bits de configuracion, por favor

;revisar el archivo P18F4550.INC para informacion adicional de la notacion

;Abajo hay algunos ejemplos



;********   Configuracion del Oscilador   **********

    CONFIG   FOSC = XT_XT               ;Osc XT, XT usado para el USB

   

;********   Otros bits de configuracion   **********

   CONFIG   PWRT = ON               ;PWRT habilitado

   CONFIG   BOR  = OFF               ;Brown out resete deshabilitado

   CONFIG   WDT    = OFF               ;Watch dog deshabilitado   

   CONFIG  MCLRE = OFF               ;MCLR como entrada

   CONFIG   PBADEN = ON               ;Todos los pines como entradas analogicas

   CONFIG   LVP   = OFF               ;programacion en bajo voltaje deshabilitado

;*********   Bits de proteccion   ******************

   CONFIG   CP0   = OFF               ;los bloques del codigo de programa

   CONFIG   CP1   = OFF               ;no estan protegidos

   CONFIG   CP2   = OFF

   CONFIG   CP3   = OFF

   CONFIG   CPB   = OFF               ;Sector Boot no esta protegido

   CONFIG   CPD   = OFF               ;La EEPROM no esta protegida

;******************************************************************************


Hola Sander una pregunta de donde sacas los valores esos para la configuracion de los bits, si yo por ejm quisiera usa el pll y un oscilador externo como se que valores colocar ahi, anteriormente estaba usando estos:

   __CONFIG   _CONFIG1H, _FOSC_XT_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H      
   __CONFIG   _CONFIG2H, _WDT_OFF_2H; & _WDTPS_32768_2H               __CONFIG   _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L

y cuando los compilo me aparece que las directivas son obsoletas :D :D para los pic18 y me dice que use CONFIG, al ser asi suprimi las barras bajas __CONFIG -->  CONFIG   y mantuve lo demas pero me sale error y bueno al colocar las tuyas todo anda bien :-/ :-/ :-/  y quisiera saber como o de donde sé los valores que debo de colocar, un saludo desde cbba 8) 8)

Desconectado sander

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 624
Re: Ejemplos PIC18F4550
« Respuesta #24 en: 09 de Febrero de 2011, 15:48:19 »
Hola c@lic_0, yo saque los  valores  para los bits de configuracion del archivo p18f4550.inc, en la parte final de ese archivo encontraras el siguiente texto comentado:

Código: [Seleccionar]
;==========================================================================
;
;   IMPORTANT: For the PIC18 devices, the __CONFIG directive has been
;              superseded by the CONFIG directive.  The following settings
;              are available for this device.
;
;   PLL Prescaler Selection bits:
;     PLLDIV = 1           No prescale (4 MHz oscillator input drives PLL directly)
;     PLLDIV = 2           Divide by 2 (8 MHz oscillator input)
;     PLLDIV = 3           Divide by 3 (12 MHz oscillator input)
;     PLLDIV = 4           Divide by 4 (16 MHz oscillator input)
;     PLLDIV = 5           Divide by 5 (20 MHz oscillator input)
;     PLLDIV = 6           Divide by 6 (24 MHz oscillator input)
;     PLLDIV = 10          Divide by 10 (40 MHz oscillator input)
;     PLLDIV = 12          Divide by 12 (48 MHz oscillator input)
;
;   System Clock Postscaler Selection bits:
;     CPUDIV = OSC1_PLL2   [Primary Oscillator Src: /1][96 MHz PLL Src: /2]
;     CPUDIV = OSC2_PLL3   [Primary Oscillator Src: /2][96 MHz PLL Src: /3]
;     CPUDIV = OSC3_PLL4   [Primary Oscillator Src: /3][96 MHz PLL Src: /4]
;     CPUDIV = OSC4_PLL6   [Primary Oscillator Src: /4][96 MHz PLL Src: /6]
;
;   USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1):
;     USBDIV = 1           USB clock source comes directly from the primary oscillator block with no postscale
;     USBDIV = 2           USB clock source comes from the 96 MHz PLL divided by 2
;
;   Oscillator Selection bits:
;     FOSC = XT_XT         XT oscillator (XT)
;     FOSC = XTPLL_XT      XT oscillator, PLL enabled (XTPLL)
;     FOSC = ECIO_EC       EC oscillator, port function on RA6 (ECIO)
;     FOSC = EC_EC         EC oscillator, CLKO function on RA6 (EC)
;     FOSC = ECPLLIO_EC    EC oscillator, PLL enabled, port function on RA6 (ECPIO)
;     FOSC = ECPLL_EC      EC oscillator, PLL enabled, CLKO function on RA6 (ECPLL)
;     FOSC = INTOSCIO_EC   Internal oscillator, port function on RA6, EC used by USB (INTIO)
;     FOSC = INTOSC_EC     Internal oscillator, CLKO function on RA6, EC used by USB (INTCKO)
;     FOSC = INTOSC_XT     Internal oscillator, XT used by USB (INTXT)
;     FOSC = INTOSC_HS     Internal oscillator, HS oscillator used by USB (INTHS)
;     FOSC = HS            HS oscillator (HS)
;     FOSC = HSPLL_HS      HS oscillator, PLL enabled (HSPLL)
;
;   Fail-Safe Clock Monitor Enable bit:
;     FCMEN = OFF          Fail-Safe Clock Monitor disabled
;     FCMEN = ON           Fail-Safe Clock Monitor enabled
;
;   Internal/External Oscillator Switchover bit:
;     IESO = OFF           Oscillator Switchover mode disabled
;     IESO = ON            Oscillator Switchover mode enabled
;
;   Power-up Timer Enable bit:
;     PWRT = ON            PWRT enabled
;     PWRT = OFF           PWRT disabled
;
;   Brown-out Reset Enable bits:
;     BOR = OFF            Brown-out Reset disabled in hardware and software
;     BOR = SOFT           Brown-out Reset enabled and controlled by software (SBOREN is enabled)
;     BOR = ON_ACTIVE      Brown-out Reset enabled in hardware only and disabled in Sleep mode (SBOREN is disabled)
;     BOR = ON             Brown-out Reset enabled in hardware only (SBOREN is disabled)
;
;   Brown-out Reset Voltage bits:
;     BORV = 0             Maximum setting
;     BORV = 1             
;     BORV = 2             
;     BORV = 3             Minimum setting
;
;   USB Voltage Regulator Enable bit:
;     VREGEN = OFF         USB voltage regulator disabled
;     VREGEN = ON          USB voltage regulator enabled
;
;   Watchdog Timer Enable bit:
;     WDT = OFF            WDT disabled (control is placed on the SWDTEN bit)
;     WDT = ON             WDT enabled
;
;   Watchdog Timer Postscale Select bits:
;     WDTPS = 1            1:1
;     WDTPS = 2            1:2
;     WDTPS = 4            1:4
;     WDTPS = 8            1:8
;     WDTPS = 16           1:16
;     WDTPS = 32           1:32
;     WDTPS = 64           1:64
;     WDTPS = 128          1:128
;     WDTPS = 256          1:256
;     WDTPS = 512          1:512
;     WDTPS = 1024         1:1024
;     WDTPS = 2048         1:2048
;     WDTPS = 4096         1:4096
;     WDTPS = 8192         1:8192
;     WDTPS = 16384        1:16384
;     WDTPS = 32768        1:32768
;
;   CCP2 MUX bit:
;     CCP2MX = OFF         CCP2 input/output is multiplexed with RB3
;     CCP2MX = ON          CCP2 input/output is multiplexed with RC1
;
;   PORTB A/D Enable bit:
;     PBADEN = OFF         PORTB<4:0> pins are configured as digital I/O on Reset
;     PBADEN = ON          PORTB<4:0> pins are configured as analog input channels on Reset
;
;   Low-Power Timer 1 Oscillator Enable bit:
;     LPT1OSC = OFF        Timer1 configured for higher power operation
;     LPT1OSC = ON         Timer1 configured for low-power operation
;
;   MCLR Pin Enable bit:
;     MCLRE = OFF          RE3 input pin enabled; MCLR pin disabled
;     MCLRE = ON           MCLR pin enabled; RE3 input pin disabled
;
;   Stack Full/Underflow Reset Enable bit:
;     STVREN = OFF         Stack full/underflow will not cause Reset
;     STVREN = ON          Stack full/underflow will cause Reset
;
;   Single-Supply ICSP Enable bit:
;     LVP = OFF            Single-Supply ICSP disabled
;     LVP = ON             Single-Supply ICSP enabled
;
;   Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit:
;     ICPRT = OFF          ICPORT disabled
;     ICPRT = ON           ICPORT enabled
;
;   Extended Instruction Set Enable bit:
;     XINST = OFF          Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
;     XINST = ON           Instruction set extension and Indexed Addressing mode enabled
;
;   Background Debugger Enable bit:
;     DEBUG = ON           Background debugger enabled, RB6 and RB7 are dedicated to In-Circuit Debug
;     DEBUG = OFF          Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
;
;   Code Protection bit:
;     CP0 = ON             Block 0 (000800-001FFFh) is code-protected
;     CP0 = OFF            Block 0 (000800-001FFFh) is not code-protected
;
;   Code Protection bit:
;     CP1 = ON             Block 1 (002000-003FFFh) is code-protected
;     CP1 = OFF            Block 1 (002000-003FFFh) is not code-protected
;
;   Code Protection bit:
;     CP2 = ON             Block 2 (004000-005FFFh) is code-protected
;     CP2 = OFF            Block 2 (004000-005FFFh) is not code-protected
;
;   Code Protection bit:
;     CP3 = ON             Block 3 (006000-007FFFh) is code-protected
;     CP3 = OFF            Block 3 (006000-007FFFh) is not code-protected
;
;   Boot Block Code Protection bit:
;     CPB = ON             Boot block (000000-0007FFh) is code-protected
;     CPB = OFF            Boot block (000000-0007FFh) is not code-protected
;
;   Data EEPROM Code Protection bit:
;     CPD = ON             Data EEPROM is code-protected
;     CPD = OFF            Data EEPROM is not code-protected
;
;   Write Protection bit:
;     WRT0 = ON            Block 0 (000800-001FFFh) is write-protected
;     WRT0 = OFF           Block 0 (000800-001FFFh) is not write-protected
;
;   Write Protection bit:
;     WRT1 = ON            Block 1 (002000-003FFFh) is write-protected
;     WRT1 = OFF           Block 1 (002000-003FFFh) is not write-protected
;
;   Write Protection bit:
;     WRT2 = ON            Block 2 (004000-005FFFh) is write-protected
;     WRT2 = OFF           Block 2 (004000-005FFFh) is not write-protected
;
;   Write Protection bit:
;     WRT3 = ON            Block 3 (006000-007FFFh) is write-protected
;     WRT3 = OFF           Block 3 (006000-007FFFh) is not write-protected
;
;   Configuration Register Write Protection bit:
;     WRTC = ON            Configuration registers (300000-3000FFh) are write-protected
;     WRTC = OFF           Configuration registers (300000-3000FFh) are not write-protected
;
;   Boot Block Write Protection bit:
;     WRTB = ON            Boot block (000000-0007FFh) is write-protected
;     WRTB = OFF           Boot block (000000-0007FFh) is not write-protected
;
;   Data EEPROM Write Protection bit:
;     WRTD = ON            Data EEPROM is write-protected
;     WRTD = OFF           Data EEPROM is not write-protected
;
;   Table Read Protection bit:
;     EBTR0 = ON           Block 0 (000800-001FFFh) is protected from table reads executed in other blocks
;     EBTR0 = OFF          Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks
;
;   Table Read Protection bit:
;     EBTR1 = ON           Block 1 (002000-003FFFh) is protected from table reads executed in other blocks
;     EBTR1 = OFF          Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks
;
;   Table Read Protection bit:
;     EBTR2 = ON           Block 2 (004000-005FFFh) is protected from table reads executed in other blocks
;     EBTR2 = OFF          Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks
;
;   Table Read Protection bit:
;     EBTR3 = ON           Block 3 (006000-007FFFh) is protected from table reads executed in other blocks
;     EBTR3 = OFF          Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks
;
;   Boot Block Table Read Protection bit:
;     EBTRB = ON           Boot block (000000-0007FFh) is protected from table reads executed in other blocks
;     EBTRB = OFF          Boot block (000000-0007FFh) is not protected from table reads executed in other blocks
;
;==========================================================================
;==========================================================================
;
;       Configuration Bits
;
;   NAME            Address
;   CONFIG1L        300000h
;   CONFIG1H        300001h
;   CONFIG2L        300002h
;   CONFIG2H        300003h
;   CONFIG3H        300005h
;   CONFIG4L        300006h
;   CONFIG5L        300008h
;   CONFIG5H        300009h
;   CONFIG6L        30000Ah
;   CONFIG6H        30000Bh
;   CONFIG7L        30000Ch
;   CONFIG7H        30000Dh
;
;==========================================================================

Ahi esta la explicacion para cada bit, y cada archivo inc tiene la misma informacion.

Saludos
La electrónica es el arte de manipular señales eléctricas que transportan información
Jan Davidse

Visita mi blog
Visita mi canal de youtube

Desconectado c@Lic_0

  • PIC10
  • *
  • Mensajes: 36
    • Una tasita de cafe
Re: Ejemplos PIC18F4550
« Respuesta #25 en: 09 de Febrero de 2011, 18:32:22 »
ok muchas gracias por la ayuda :-/ :-/

Desconectado c@Lic_0

  • PIC10
  • *
  • Mensajes: 36
    • Una tasita de cafe
Re: Ejemplos PIC18F4550
« Respuesta #26 en: 09 de Febrero de 2011, 20:32:30 »
yo otra vez xD¡¡ :mrgreen: :mrgreen: estuve revisando los bits de configuracion y hay muchas nuevas configuraciones de las cuales no entiendo algunas o no me doy cuenta y ando un tanto perdido, no se si me puedes echar una manito con esto :-/ :-/, o debo de abrir otro hilo. gracias

Desconectado sander

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 624
Re: Ejemplos PIC18F4550
« Respuesta #27 en: 10 de Febrero de 2011, 20:51:22 »
Hola c@lic_0, yo creo que puedes postear en este hilo tus dudas, por mi no hay problema,  pero si te recomiendo que antes de postear tus dudas primero trates de responderlas leyendo la hoja de datos del micro, es una muy buena costumbre que se debe ir adquiriendo, y si el ingles te cuesta, con gusto tratare de ayudarte.

Saludos
La electrónica es el arte de manipular señales eléctricas que transportan información
Jan Davidse

Visita mi blog
Visita mi canal de youtube

Desconectado c@Lic_0

  • PIC10
  • *
  • Mensajes: 36
    • Una tasita de cafe
Re: Ejemplos PIC18F4550
« Respuesta #28 en: 11 de Febrero de 2011, 16:45:05 »
ok ahi te va, el bit FCMEN hasta donde lo lei tengo entendido que permite asignar un oscilador RC interno en caso de que falle el oscilador externo que se esta usando (a no ser que lo entendi mal :D :D) y en el datasheet muestra la imagen(esta en adjuntos, no se como colocar la imagen aqui), ahora como sabe ese oscilador interno RC a que frecuencia debe oscilar o soy yo el que lo debe de configurar y el postcaler que tiene es fijo? o tb se configura  :-/ :-/ :-/


Desconectado Suky

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 6758
Re: Ejemplos PIC18F4550
« Respuesta #29 en: 11 de Febrero de 2011, 19:07:05 »
Busca en el datasheet sobre OSCCON  ;-)


Saludos!
No contesto mensajes privados, las consultas en el foro


 

anything