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

Code Help with interrupts

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







Code Help with interrupts
PostPosted: Sun Jan 19, 2003 8:04 am     Reply with quote

Hi Folks!
I'm new in CCS compiler and I'm trying to do a program to count some quantities and my program does not work as I wish. I have an 74C922 (keypad 16 key encoder) with pin DA connected to my RB0/INT pin. It reconize that I pressed a button and gives me a correct value ( Tecla variable ) and set Tec_Press bit, that indicates me that a key was pressed. If I press "A" key in my keypad (value 10 decimal) my program switches to FuncaoA() and it can't leave that function until I press again a "A" key, because I have an infinite loop that tests every time if I had a key pressed (bit Tec_Press=1), but in fact it returns to my switch function at main() function (it is visible if I press "B" key it shows me the text "Function B" in my LCD). Any suggestion?
Another point is that i want to read 4 values from my keypad and store it in one variable (Qtde) - for example, I press 3 followed by 4 followed by 5 followed by 7 and my Qtde var must have 3457 stored (in order 1000's, 100's, 10's and 1's). How can I do that?
Thanks a lot,
Luis

#int_ext
UCHAR le_tec()
{
bit_set(Tec_Press);
set_tris_b(0xF1);
Tecla=PORT_B;
Tecla=swap(Tecla)&0x0F;
set_tris_b(0x01);
}


void main( void )
{
Qtde=0000;
QtdeBL=0001;
bit_clear(Tec_Press);
enable_interrupts(global);
enable_interrupts(int_ext);
set_tris_b ( 0x01 ); /* Bit 0 is input */
set_tris_a ( 0x00 );
LCD_Init(); // initializes display
CMD_LCD(CLEAR_DISP);
delay_ms(2);
printf(CHAR_LCD," Ready");
for (;;)
{
if (bit_test(Tec_Press))
{
switch (Tecla)
{
case 10: FuncaoA(); break;
case 11: FuncaoB(); break;
}
}
}
}

FuncaoA()
{
bit_clear(Tec_Press);
// Tec_Press==0;
CMD_LCD(0x01);
delay_ms(2);
printf(CHAR_LCD,"Quantity \%04ld",Qtde);
CMD_LCD(0xC0);
printf(CHAR_LCD,"Blocks \%04ld",QtdeBL);
CMD_LCD(0x8C); // Set column
CMD_LCD(0x0F); // Blinking Cursor
for(;;)
{
while (bit_test(Tec_Press)) {};
CHAR_LCD(Tecla+0x30);
if (Tecla==10) return;
}
CMD_LCD(0x8C); // Set column
}
FuncaoB()
{
bit_clear(Tec_Press);
// Tec_Press==0;
printf(CHAR_LCD,"Function B");
if (bit_test(Tec_Press))
{
if (Tecla==11) return;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 10800
kolio
Guest







Re: Code Help with interrupts
PostPosted: Mon Jan 20, 2003 2:10 am     Reply with quote

Hi,
when you're pressing "A" key then an interrupt appears (74C922 to EXT Int), but what will happen when you're releasing the key ? I don't see where the key release is processed.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10810
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