18F4550 to 18F2550


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Location
    Venezuela - Caracas
    Posts
    48

    Question 18F4550 to 18F2550

    i try this code with 18F4550 and work 1000%
    i change code for 18F2550 and not work, not Recognised

    Resonator 4Mhz
    4k7 in Mclr
    470nf in Vusb
    0,1nf in Vdd-Vcc

    Vusb - 4550 = 3,31
    Vusb - 2550 = 3,37


    Code:
       '   =================
       asm
          __CONFIG    _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
                                   ;              ;                      ; USB clock source comes from the 96 MHz PLL divided by 2
                                   ;              ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
                                   ; No prescale (4 MHz oscillator input drives PLL directly)
    
    
          __CONFIG    _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H 
                                   ;                  ;               ; Oscillator Switchover mode disabled
                                   ;                  ; Fail-Safe Clock Monitor disabled
                                   ; XT oscillator, PLL enabled, XT used by USB
          __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
          __CONFIG    _CONFIG2H, _WDT_OFF_2H 
          __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
          ;__CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
          __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L 
       endasm
       
       DEFINE OSC 48          
        
        '
        '   Hardware configuration
        '   ======================    
            '
            '   I/O and PORTs
            '   -------------  
        PORTB   =   0
        PORTC   =   0
    '    PORTD   =   0 ' enable for 18f4550
    '    PORTE   =   0 ' enable for 18f4550
        TRISB   =   0
        TRISC   =   0
        TRISA   =   $FF
    '    TRISD   =   0 ' enable for 18f4550
    '    TRISE   =   0 ' enable for 18f4550
    
       ' USB modulo
       UCFG    var byte EXT        ' include UCFG register... Yeah Melabs didn't :o(
       ucfg    =   %00010100       ' enable internal USB pull-up, Full speed USB
    
       ' Interruptores
       INTCON  =   %10100000       ' Enable global and TMR0 interrupts
       T0CON   =   %10000000       ' TMR0, CLK internal, prescaler 1:2, T0ON
    
        '   
        '   Variables & constants definition 
        '   ================================
       I  Var Byte
    
       USBBufferSizeTX     con 8       ' input 
       USBBufferSizeRX     con 8       ' output
    
       Usb_Contador        Var Byte    '
       Usb_Dados           var byte[8] ' store ADCs & pushButton data to send to USB
    
       ' Constantes
       TMR0IF              VAR INTCON.2 ' TMR0 overflow int flag
       TMR0ON              VAR T0CON.7  ' TMR0 on/off bit
       TMR0IE              VAR INTCON.5 ' TMR0 interrupt enable/disable bit
    
       ' Macros
       goto Configura
    
        asm 
    Reload_TMR0 macro
        BCF     _TMR0ON         ; stop timer
        MOVE?CW d'65000',TMR0L  ; reload for timebase ~100uSec
        BCF     _TMR0IF         ; clear overflow flag
        BSF     _TMR0ON         ; start timer
        ENDM
        endasm
    
    '-------------------------------------------------------------------------------
    Configura:
        pause 500
        usbinit
    @   Reload_TMR0
        ON INTERRUPT GOTO Usb_Servico
    
    '-------------------------------------------------------------------------------
    Inicio:
       gosub Usb_Entrada
    goto Inicio
    
    '-------------------------------------------------------------------------------
    Usb_Entrada:
       tmr0ie = 0
       Usb_Contador = USBBufferSizeRX
    
       USBService
       USBIn 3, Usb_Dados, Usb_Contador, Timeout
       
       GOSUB Usb_Saida
    return
        
    Timeout:
    @   Reload_TMR0            
       tmr0ie = 1
    return
    
    '-------------------------------------------------------------------------------
    Usb_Saida:
       TMR0IE = 0
       
    WaitPC:
       'Usb_Contador = USBBufferSizeTX
       
       USBService
       USBOut 3, Usb_Dados, Usb_Contador, Waitpc
    @   Reload_TMR0                                     
       tmr0ie = 1
    return
    
    '-------------------------------------------------------------------------------
    DISABLE
    Usb_Servico:
       usbservice
    @   Reload_TMR0
       RESUME
    ENABLE
    Last edited by mpardinho; - 28th September 2007 at 14:42.

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    for 18F2550 I use:

    _CONFIG1H, _FOSC_HSPLL_HS_1H

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Somehow strange... i posted examples of the USBDemo that worked on the following link.
    http://www.picbasic.co.uk/forum/show...8&postcount=99

    the whole set of config fuses for a 4MHz crystal was
    Code:
        '
        '   Pic Configuration
        '   =================
        asm
        __CONFIG    _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
                                ;              ;                      ; USB clock source comes from the 96 MHz PLL divided by 2
                                ;              ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
                                ; No prescale (4 MHz oscillator input drives PLL directly)
    
    
        __CONFIG    _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H 
                                ;                  ;               ; Oscillator Switchover mode disabled
                                ;                  ; Fail-Safe Clock Monitor disabled
                                ; XT oscillator, PLL enabled, XT used by USB
                                
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L 
        endasm
        DEFINE OSC 48
    Unless i need new glasses... can i suspect some wiring or device programmer problem?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. 18f4550 usb problem.. so im getting crazy..
    By MeSaKu in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th May 2009, 22:03
  2. 18F2550 timing
    By sstt1976 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 22nd August 2008, 00:30
  3. Usb Mass Storage With 18f4550
    By wagner in forum USB
    Replies: 8
    Last Post: - 17th August 2008, 16:46
  4. How can I turn off USB support in 18F4550
    By BrianT in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2007, 03:56
  5. USB Programmer for 18F4550 PICs
    By Kamikaze47 in forum USB
    Replies: 8
    Last Post: - 21st August 2007, 16:29

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts