Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Yes.... key is a number 0 ~ 12... to see it you need to convert to ascii... ie add 48 to key..
LCD_Data(key+48);
He would change this
Code:char act_key[] = {0,1,4,7,11,2,5,8,10,3,6,9,12} ; use ascii replace the numbers with the ascii '1', '2', to match key pad. '+' so on.
correct, now the problem is that it show the key 5 without pressing any key (using keil) that mean's function return only one key that is 5The problem with what Ian said is your wanting - and + and = keys key+48 not going to work.
You need change the part I showed you char act_key[] = {0,1,4,7,11,2,5,8,10,3,6,9,12} ;
To some thing like this with the keys you want
char act_key[] ={ '1','2','3','4','5','6','7','8', '9','0','-','+', '='};
if(key>9)
{
switch(key)
{
case 10: call do_ten ; break;
// etc..
The reason a key pad returns the number is so you can process it..
char keypad(void)
{
unsigned char keymask = 0xEF;
char key = 0, row;
char act_key[] ={'1','2','3','4','5','6','7','8', '9','0','-','+', '='};
for(row = 0; row < 4; row++)
{
KEYport = keymask;
if(!C1) key = 1;
if(!C2) key = 2;
if(!C3) key = 3;
if(!C4) key = 4;
if(key)
{
key = key +(row*4);
return act_key[key];
}
keymask <<= 1;
keymask ++;
}
return key;
}
What I don't get... You work with Proteus.... Proteus can integrate SDCC.. Then you can use the debug file to single step through the code... Why don't you just stick with SDCC... Its a better compiler but without the libraries..Code works well on the sdcc But I have worked on keil yet. I think I should not change the compiler for one program So, I want this code to work on keil. I am trying to figure out where the mistake is happening
if I use sdcc What files do I have to load to debug codes on Proteus?What I don't get... You work with Proteus.... Proteus can integrate SDCC.. Then you can use the debug file to single step through the code... Why don't you just stick with SDCC... Its a better compiler but without the libraries..
SDCC... Its a better compiler but without the libraries.
I have installed sdccSDCC outputs these file
The omf and cdb are the debug files..
If you create the firmware in VSM make sure you uncheck "Embed files" then you will get the list I have shown..
I was following this link https://www.instructables.com/id/8051-Programming-Using-Small-Device-C-Compiler-SDC/You have to install it.. Mine is in program files... It shouldn't be on the desktop
I am just trying with led blink code. LED is blinking but how to debug codeProteus is the GUI.... All you need to do is install SDCC then let VSM search for compilers.. VSM is Proteus's inbuilt code editor..
..
/* Main.c file generated by New Project wizard
*
* Created: Sun Feb 11 2018
* Processor: AT89C51
* Compiler: SDCC for 8051
*/
#include <mcs51reg.h>
#define LED_ON 1 /* LED ON */
#define LED_OFF 0 /* LED OFF */
/* LED connected to port P1 of pin 0 */
#define LED P1_0
/* This is delay function */
void Delay (unsigned int n)
{
unsigned int i;
for (i = 0; i <n; i++);
{
}
}
void main(void)
{
LED = LED_OFF; /* LED OFF */
while (1)
{
LED = LED_ON; /* Turn ON LED */
Delay(37000); /* Wait 40 ms */
LED = LED_OFF; /* turn off LED */
Delay(18500); /* wait 20ms */
}
}
I can see, there is c file and 8051 cpu variables window but I don't understand what's happening. I have never done this beforeWhat I do.... View attachment 110921 Press the second Icon... And the first line of code "LED = LED_OFF;" will be highlighted... then press F10 to step and F11 to step into..