CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

pin timing of 16F887

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

pin timing of 16F887
PostPosted: Wed Jun 10, 2009 5:07 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 10, 2009 5:32 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 11, 2009 7:56 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 11, 2009 12:29 pm     Reply with quote

..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

View user's profile Send private message

PostPosted: Thu Jun 11, 2009 1:07 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 11, 2009 1:31 pm     Reply with quote

Got it working. Thanks!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group