PIC18F4550 question VS PIC16F887


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default PIC18F4550 question VS PIC16F887

    Hello,

    I have a code that works good with the PIC16F887, I want to be able to use it on the 18F4550 chip, the only change I made is to remove the ANSELH = 0 line, It compiles and write to the chip, but nothing is showing on my LCD. The pins are 97% identical between the two chips. This is the first time I am using the 4550 chip or any chip in the 18 series. Can someone tell me why nothing is showing up on the LCD
    thanks


    Code:
    DEFINE OSC 8
    'ANSELH = 0
    
    
    '/////////////////////////
    '// LCD configuration //
    '/////////////////////////
    
    DEFINE LCD_DREG PORTB 	' Set LCD Data port
    DEFINE LCD_DBIT 4 		' Set starting Data bit (0 or 4) if 4-bit bus  RB.4, RB.5, RB.6, RB.7
    DEFINE LCD_RSREG PORTB 	' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 		' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB	' Set LCD Enable port
    DEFINE LCD_EBIT 0 		' Set LCD Enable bit
    DEFINE LCD_BITS 4 		' Set LCD bus size (4 or 8 bits) '4 therefore put wire at 4, 5, 6 and 7 of LCD
    DEFINE LCD_LINES 2 		' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 1000
    
                  DPIN    VAR PORTD.3    'I2C DATA PIN
                  CPIN    VAR PORTC.3    'I2C CLOCK PIN
    
                  ' -------------- RTC definitions -----------------
              RTC CON     %11010000
              SecReg CON $00 ' seconds Write_Addressess (00 - 59) ' MSB of SecReg must be set to a 0 to enable RTC
              ContReg CON $0E ' control register
              cntrl CON %00000000 ' sets the SQW/OUT to 1Hz pulse, logic level low
              I2CWRITE DPIN, CPIN, RTC, ContReg, [cntrl]
              ' The variable below holds the values entered:
              ' entered by the user
    TempVal var byte
    Temp1 var byte
    Temp2 var byte
    i var byte
    j var word
    sec VAR BYTE : mins VAR BYTE : hr VAR BYTE : day VAR BYTE :date VAR BYTE : mon VAR BYTE : yr VAR BYTE 
    Write_Address    VAR WORD
    Battery_Charge_Counter var byte
    Battery_Charge_Counter = 0
    Write_Address = 0 	
    B0 var byte
    B0 =0
    GOSUB SET_RTC
                 
    Mainloop:
    
    	lcdout $FE,1, "Appuye sur Record"
    	lcdout $FE,$C0, "ou sur Show"
    	pause 100
    	
    	 BUTTON PORTC.6,0,10,5,B0,1,Button_pressed
    		
    
    
    			
    		if PORTC.7 =0 then 
    			if Write_Address = 0 then goto Mainloop
    			j = 0
    			For i=0 to (Write_Address / 3) -1	
                  I2CREAD DPIN,CPIN,$A0,j,[sec,mins,hr]
                  PAUSE 10
                  LCDOUT $FE,1," Time  ",DEC2 i
                  LCDOUT $FE,$C0,"WA ",DEC j," T:", dec2 hr, ":", dec2 mins, ":", dec2 sec
                  PAUSE 1000
                   j =j + 3
                 next i
    		Endif
    			
    GOTO Mainloop
    End
    Button_pressed:
    				GOSUB READ_RTC
    				I2CWRITE DPIN,CPIN,$A0,Write_Address,[sec,mins,hr]
    				PAUSE 10
    				Write_Address = Write_Address +3
    
    Goto Mainloop
    				
    READ_RTC:
         I2CREAD DPIN, CPIN, $D0, SecReg, [sec,mins,hr,day,date,mon,yr]
    	 pause 10
    	 			TempVal=hr
    				GoSub BCD_TO_BIN
    				hr=TempVal
    				
                    TempVal=sec
    				GoSub BCD_TO_BIN
    				sec=TempVal
    
    				TempVal=mins
    				GoSub BCD_TO_BIN
    				mins=TempVal
    RETURN
    
    SET_RTC:		' Do once at startup
        yr = $3
        mon = $5
        date = $05
        sec = $09
        mins = $07
        hr = $06
        I2CWRITE DPIN, CPIN, $D0, SecReg, [sec,mins,hr,day,date,mon,yr]
     RETURN
     
     BCD_TO_BIN:                                    ' Convert the BCD values into BIN
    
         Temp1 = $0F & TempVal                     ' Clear off the top four bits
         Temp1 = Temp1 Dig 0
         Temp2 = TempVal >> 4                       ' Shift down four to read 2 BCD value
         Temp2 = Temp2 Dig 0
         TempVal = Temp2 * 10 + Temp1
    
    Return

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 question VS PIC16F887

    What are you using for the OSC and did you change the configs to match?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 question VS PIC16F887

    This is the exact program that i use for the PIC16F887. except ansel=0.
    using internal osc at 8mhz

    K

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 question VS PIC16F887

    Then change the configs to use the internal...
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 question VS PIC16F887

    I added a 20Mhz crystal and change the line to DEFINE OSC 20
    works better, I think I will change the capacitor because the text is off.
    Ok now I guess why cant i use the internal oscillator even using this do not work:
    OSCCON = %01110000 '8 Mhz
    DEFINE OSC 8

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 question VS PIC16F887

    Does your configs look like this?
    This is for the internal
    Code:
    @ __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG    _CONFIG1H, _FOSC_INTOSCIO_EC_1H
    @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L &_XINST_OFF_4L
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: PIC18F4550 question VS PIC16F887

    well not really Dave
    here is what I get when I compile:
    Executing: "C:\PBP2.60\PBPMPLAB.BAT" -ampasmwin -k# -p18F4550 "both.bas"
    Executing: "C:\PBP2.60\PBPW.EXE" -ampasmwin -k# -p18F4550 "both.bas"
    PICBASIC PRO(TM) Compiler 2.60A, (c) 1998, 2010 microEngineering Labs, Inc.
    All Rights Reserved.

    ERROR: Unable to execute mpasmwin.Error[118] C:\PBP2.60\BOTH.ASM 184 : Overwriting previous address contents (0000)
    Error[118] C:\PBP2.60\BOTH.ASM 184 : Overwriting previous address contents (0001)
    Skipping link step. Not all sources built successfully.
    BUILD FAILED: Sat Feb 19 14:31:44 2011


    this is the code header I used:
    Code:
    @ __CONFIG    _CONFIG1H, _FOSC_INTOSCIO_EC_1H
    DEFINE OSC 8

Members who have read this thread : 0

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