archive:nmk322
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
archive:nmk322 [2024/11/12 22:56] – [Library: Keypad] azman | archive:nmk322 [2024/12/19 11:56] (current) – [Lecture Slides] azman | ||
---|---|---|---|
Line 15: | Line 15: | ||
* Lecture 3 - {{: | * Lecture 3 - {{: | ||
* Lecture 4 - {{: | * Lecture 4 - {{: | ||
+ | * Lecture 5 - {{: | ||
+ | * Lecture 6 - {{: | ||
+ | * Lecture 7 - {{: | ||
+ | * Lecture 8 - {{: | ||
===== Library Codes ===== | ===== Library Codes ===== | ||
Introduction to using ' | Introduction to using ' | ||
+ | |||
+ | I recommend to use my include file (mcu51.h) rather than the regular (reg51.h) because it would be easier for you to use my example codes and library. I wrote and tested them using my own syntax that can be used on both Keil and SDCC compilers. Simply extract this {{: | ||
==== Library: Serial (UART) ==== | ==== Library: Serial (UART) ==== | ||
Line 253: | Line 259: | ||
#endif | #endif | ||
#ifndef _ROWS_AT_UPPER_ | #ifndef _ROWS_AT_UPPER_ | ||
+ | #define ROWS_FLAG 0x01 | ||
+ | #define COLS_FLAG 0x10 | ||
+ | #else | ||
#define ROWS_FLAG 0x10 | #define ROWS_FLAG 0x10 | ||
#define COLS_FLAG 0x01 | #define COLS_FLAG 0x01 | ||
- | #else | ||
- | #define ROWS_FLAG 0x01 | ||
- | #define COLS_FLAG 0x10 | ||
#endif | #endif | ||
Line 270: | Line 276: | ||
KEY_DATA = ~mask; test = COLS_FLAG; | KEY_DATA = ~mask; test = COLS_FLAG; | ||
for (icol=0; | for (icol=0; | ||
+ | if ((KEY_DATA& | ||
+ | while ((KEY_DATA& | ||
+ | if (icol==3) return irow+0x0A; | ||
+ | if (irow==0) return icol+1; | ||
+ | if (irow==1) return icol+4; | ||
+ | if (irow==2) return icol+7; | ||
+ | if (icol==1) return 0; | ||
+ | return (icol>> | ||
+ | } | ||
test <<= 1; | test <<= 1; | ||
} | } |
archive/nmk322.1731423380.txt.gz · Last modified: by azman