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 CCS Technical Support

Problems with 18f2550 and kbd

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



Joined: 26 May 2010
Posts: 2

View user's profile Send private message

Problems with 18f2550 and kbd
PostPosted: Wed May 26, 2010 3:21 pm     Reply with quote

Hey you all. So I know it's pretty sad when a person joins a forum just to post a question, but well, that is, sadly, the case.... The thing is that I've been trying to program this kbd in my 18f2550 and damn I haven't been able. A teacher, who isn't exactly proficient handling 18f's, told me that I'm probably missing some simple line somewhere that isn't letting me handle the kbd properly, since well, I'm mostly copying the configuration from 16f's that I've seen and handled before.

So I made this simple code up to try to configure the device, but still doesn't work (the only button that works is pressing '2' and it ends up taking it as a '1'):

Code:

#INCLUDE <18F2550.h>
#USE DELAY(CLOCK=4000000)
#FUSES XT,NOPROTECT,NOWDT,NOBROWNOUT,PUT,NOLVP
#DEFINE USE_PORTB_LCD TRUE                                   


#DEFINE USE_PORTB_KBD

#INCLUDE <LCD.C>
#INCLUDE <KBD.C>

#BYTE PORTB=3969

char seleccion;

void main(void)
{

PORT_B_PULLUPS(TRUE);                                       

LCD_INIT();
KBD_INIT();

while(true)
{
seleccion=0;
seleccion=kbd_getc();

if(seleccion!='\0')
{
lcd_putc("\f");
lcd_gotoxy(1,1);
lcd_putc(seleccion);
delay_ms(5000);

}

}

}



oh yes, as you could tell i'm also using a lcd in the same port to check if it's working.... so this is the schematic I'm using that doesn't seem to work:



also, the reason i'm using this particular pic is because the 16f's rom is too little and i haven't actually finished the whole program i'm trying to do... so yeah that's all.... any help will be highly appreciated!
(:
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 26, 2010 3:27 pm     Reply with quote

Do you have to put the LCD and the keypad on the same port ?
Why not put the LCD on a different port ?

Also, you should not put the command to clear the screen in double
quotes. It should be in single quotes, like this:
Code:

lcd_putc('\f');
 


Also, you should not use decimal for register addresses. No one knows
what it means. The PIC data sheet uses Hex. Do it like this:
Code:
#byte PortB = 0xF81
Herl91



Joined: 26 May 2010
Posts: 2

View user's profile Send private message

PostPosted: Wed May 26, 2010 3:55 pm     Reply with quote

ok... done, and done.... and yeah, i do have to use the same port since the others will be inputs for some adc's for position sensors and one of them a control signal for a motor... I haven't actually counted how many pins will all that use, but I'm sure it will not be enough for the LCD to have a single port all for itself....

but still, should this program and configuration work this way? I mean, i'm no expert in 18f's but is it that different?

a buddy told me that maybe is the version of proteus i'm using that isn't letting me simulate the program right... any thoughts? anyone out there care to check if that might be the problem? (i'm using a portable version of proteus at the moment, i could get my hands in another tonight, tho)
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