| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| treitmey 
 
 
 Joined: 23 Jan 2004
 Posts: 1094
 Location: Appleton,WI   USA
 
 
			      
 
 | 
			
				| pin timing of 16F887 |  
				|  Posted: Wed Jun 10, 2009 5:07 pm |   |  
				| 
 |  
				| CCS Ver 3.249 18F452/16F887 running at 18.432000MHz I'm debugging why my LCD isn't working on port A.
 Code runs OK with 18F452 but if I swap to 16F887 it doesn't.
 Looking at pin A0 with scope the 18F452 makes a 30uS wide signal but the 16F887 is much smaller, 1.4uS.  Can anyone tell me why?
 
  	  | Code: |  	  | #include <18F452.h> //#include <16F887.h>
 #use delay(clock=18432000)
 #use rs232(baud=1200,errors,xmit=PIN_C6,rcv=PIN_C7,parity=e,enable=PIN_C5,stream=CIM)
 #use rs232(baud=19200,xmit=PIN_D7,invert,stream=DEBUG)
 #case
 #zero_ram
 #define LCD_RS   PIN_A0 //<-- oscope on this pin, other have simular width
 #define LCD_E    PIN_A1 //note no RW
 #define LCD_DB4  PIN_A2
 #define LCD_DB5  PIN_A3
 #define LCD_DB6  PIN_A4
 #define LCD_DB7  PIN_A5
 
 #include "LCD.c"
 //#include "flex_lcd.c"
 
 //======================= Main ==============================
 void main(void)
 {
 setup_adc_ports(NO_ANALOGS);
 #define BEEP   PIN_C0
 #define RELAY  PIN_C1
 #define XMTHEN PIN_C5
 
 output_low(BEEP);
 output_low(RELAY);
 output_low(XMTHEN);//turn off the TX_enable
 //make sure we start with relays not activated
 //===================== STARTUP SCREEN=====================//
 fprintf(DEBUG,"Starting\n\r");
 lcd_init();
 while(1)
 {
 lcd_putc("\fHello There");
 //fprintf(DEBUG,".");
 }
 }
 
 | 
 ..update ..
 Tried a 16F877 and it works,.. but not 16F887
 |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jun 10, 2009 5:32 pm |   |  
				| 
 |  
				|  	  | Quote: |  	  | CCS Ver 3.249 18F452/16F887 | 
 I just installed vs. 3.249 and I can't find the 16F88x files in it.
 Did you add the 16F887 by yourself, using the Device Editor ?
 |  | 
	
		|  | 
	
		| treitmey 
 
 
 Joined: 23 Jan 2004
 Posts: 1094
 Location: Appleton,WI   USA
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Thu Jun 11, 2009 7:56 am |   |  
				| 
 |  
				| Yes.  I used the 16F877A as starting point.. both have 8K words for programming and 256 data eeprom and portA at 5 and trisa at 0x85. I'll try it again,... I seem to remember guessing at how to do something or another.  I'm sure re-doing it will refresh my memory.
 |  | 
	
		|  | 
	
		| treitmey 
 
 
 Joined: 23 Jan 2004
 Posts: 1094
 Location: Appleton,WI   USA
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Thu Jun 11, 2009 12:29 pm |   |  
				| 
 |  
				| ..update.. still can't fix it. would a 16F877a hex programed onto the 887 work?  at least for port A?
 |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Jun 11, 2009 1:07 pm |   |  
				| 
 |  
				| Part of the problem is likely the ANSEL and ANSELH registers in the 16F887.   They power-up as all 1's, which sets much of Port A and Port B
 as analog pins.  If you just defined those register addresses with #byte
 statements and then set both registers to 0x00 at the start of main(),
 it might cure your problems.
 
 
  	  | Quote: |  	  | setup_adc_ports(NO_ANALOGS); | 
 Because you created the 16F887 with the Device Editor, there's no
 guarantee that this line is writing to the correct registers.   I would
 delete this line and do it manually, as I suggested above.
 
 Be aware that many of the built-in functions may not work correctly
 with your created version of the 16F887.
 |  | 
	
		|  | 
	
		| treitmey 
 
 
 Joined: 23 Jan 2004
 Posts: 1094
 Location: Appleton,WI   USA
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Thu Jun 11, 2009 1:31 pm |   |  
				| 
 |  
				| Got it working. Thanks! |  | 
	
		|  | 
	
		|  |