Skip to content

Instantly share code, notes, and snippets.

View Embedded-linux's full-sized avatar
πŸ’­
I may be slow to respond.

G Satish Kumar Embedded-linux

πŸ’­
I may be slow to respond.
  • Cavium Networks
  • Bangalore
View GitHub Profile
#include ”../FlashOs.H”
// Memory Mapping Control
#define MEMMAP (*((volatile unsigned char *) 0x E01FC040))
// Phase Locked Loop (PLL)
#define PLLCON (*((volatile unsigned char*) 0xE01FC080))
@Embedded-linux
Embedded-linux / RTC for LPC2148
Last active December 22, 2015 07:19
Setting Time To RTC for LPC2148
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Example for Real time clock
// Description : Example for display via Terminal program time format hh:mm:ss
// : and user can setup new time by press key β€˜*’ on keyboard
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : rtc_setup.c
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
#include β€œlpc214x.h” // Header file for Phillips LPC2148 controller
#include β€œstdio.h” // Library for use puts function(For UART1)
Note:
the operation of this experiment RTC module cannot operate
continuous without supply voltage. Because the program set to RTC clock use
same souce clock of CPU (CLKSRC bit in CCR register is β€˜0’). RTC module will operate
when apply supply voltage to CPU only
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Example for Real time clock
// Description : -
@Embedded-linux
Embedded-linux / ADC for LPC 2148
Created September 4, 2013 14:02
ADC for LPC 2148
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Example Analog to Digital converter
// Description : Display A/D convert value on terminal program(used UART0
// : communication)
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : adc.c
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
#include β€œlpc214x.h” // Header file for Phillips LPC2148 controller
#include β€œstdio.h” // Library for sprintf function
@Embedded-linux
Embedded-linux / UART for LPC2148
Created September 4, 2013 14:04
UART for LPC 2148
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : UART example
// Description : Example for test UART1 interrupt mode
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : uart_int.c
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
#include β€œlpc214x.h” // Header file for Phillips LPC2148 controller
#include β€œuart.h” // Library for use module UART0,UART1
#include β€œstdio.h” // Library for use puts function(For UART1)
@Embedded-linux
Embedded-linux / UART0 and UART1
Created September 4, 2013 14:07
Transmit Data From UART0 & UART1
Transmit Data from UART0/UART1 module on LPC 2148
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Library for serial communication(UART)
// Description : Library for about serial communication UART0 and UART1 of LPC2148
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : uart.h
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
#define _PCLK 30000000 // Define PCLK for configuration baudrate
@Embedded-linux
Embedded-linux / EINT2 for LPC2148
Created September 4, 2013 14:09
External Interrupt2 for LPC2148
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Example for EINT2(External interrupt2)
// Description : Test interrupt from switch press display by LED at P0.21
// : toggle and sound beep
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : ext_int2.c
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
#include β€œlpc214x.h” // Header file for Phillips LPC2148 controller
#include β€œsound.h” // Header file for Phillips LPC2148 controller
LPC2148 port acts input for reading data
from P0.28 and P0.29 that connected with push-button switches and resistor pull-up
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
// Program : Example for test switch
// Description : Test switch at P0.28 and P0.29 for toggle LED at P0.21 and P0.22
// Frequency : Crystal 12 MHz at PLL 5x(CCLK = 60 MHz),PCLK = 30 MHz
// Filename : switch.c
// C compiler : Keil CARM Compiler
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”//
@Embedded-linux
Embedded-linux / WDT for LPC2148
Created September 4, 2013 14:13
WDT for LPC2148
Reference user manual :
http://www.keil.com/dd/docs/datashts/philips/user_manual_lpc2119_2129_2194_2292_2294.pdf
/* WDT [Watch Dog Timer] driver for LPC2129 */
#include <LPC210x.H> /* LPC210x definitions */
extern void init_serial (void); /* Initialize Serial Interface */
extern int sendchar (int ch); /* Write character to Serial Port */
@Embedded-linux
Embedded-linux / Serial Interfacing for LPC2129
Created September 4, 2013 14:17
Serial Interfacing for LPC2129
Reference user manual :
http://www.keil.com/dd/docs/datashts/philips/user_manual_lpc2119_2129_2194_2292_2294.pdf
/*Serial interfacing for LPC2129 [NXP] UART1*/
#include <LPC210x.H> /* LPC21xx definitions */