Академический Документы
Профессиональный Документы
Культура Документы
Dr Ramani Kalpathi
Professor, St. Josephs College of
Engineering
Agenda
Introduction to ARM Cortex-M0 Nuvoton-
NuMicro family
Programming Tools for ARM processors
NuMicro Learning Board Hardware Peripherals
NuTiny NUC140 Project Board
Keil Integrated Design Environment Tool Chain
Assembling, compiling, linking and Load
process
Compilation using C language, Build process
ARM processor peripherals
Applications using peripherals-ADC, Timer, I/O
NuMicro Cortex-MO
NuMicro NUC100 Series includes NUC100,
NuMicro Family
NU-TINY-SDK 140
update
Clock
Flexible selection for different applications
Built-in 22.1184 MHz high speed OSC for system operation
Trimmed to
Timer
Support 4 sets of 32-bit timers with 24-bit up-timer and
one 8-bit pre-scale counter
Independent clock source for each timer
Provides one-shot, periodic, toggle and continuous
counting operation modes
Support event counting function
Support input capture function
Watchdog Timer
Multiple clock sources
8 selectable time out period from 1.6ms ~ 26.0sec
(depends on clock source)
WDT can wake-up from power down or idle mode
Interrupt or reset selectable on watchdog time-out
UART
Up to three UART controllers
UART ports with flow control (TXD, RXD, CTS and
RTS)
UART0 with 64-byte FIFO is for high speed
UART1/2(optional) with 16-byte FIFO for standard
device
Support IrDA (SIR) and LIN function
Support RS-485 9-bit mode and direction control.
Programmable baud-rate generator up to 1/16
system clock
Support PDMA mode
SPI Interface
Up to four sets of SPI controller
Master up to 32 MHz, and Slave up to 10 MHz (chip working @
5V)
Support SPI master/slave mode
Full duplex synchronous serial data transfer
Variable length of transfer data from 1 to 32 bits
MSB or LSB first data transfer
Rx and Tx on both rising or falling edge of serial clock
independently
2 slave/device select lines when it is as the master, and 1
slave/when it is as the slave
Support byte suspend mode in 32-bit transmission
Support PDMA mode
Support three wire, no slave select signal, bi-direction interface
I2C Interface
Up to two sets of I2C device
Master/Slave mode
Bidirectional data transfer between masters and slaves
Multi-master bus (no central master)
Arbitration between simultaneously transmitting masters
I2S Interface
Interface with external audio CODEC
Operate as either master or slave mode
Capable of handling 8-, 16-, 24- and 32-bit word
sizes
Mono and stereo audio data supported
I2S and MSB justified data format supported
Two 8 word FIFO data buffers are provided, one for
transmit and one for receive
Generates interrupt requests when buffer levels
cross a programmable boundary
Support two DMA requests, one for transmit and
one for receive
mask
Programmable FIFO mode (concatenation of
Message Object)
Maskable interrupt
Disabled Automatic Re-transmission mode for
Time Triggered CAN applications
Support power down wake-up function
Isochronous transfers
Auto suspend function when no bus signaling for
3 ms
Provide 6 programmable endpoints
Include 512 Bytes internal SRAM as USB buffer
Provide remote wake-up capability
Analog to Digital
Converter
12-bit SAR ADC with 700K SPS
Up to 8-ch single-end input or 4-ch
differential input
Single scan/single cycle scan/continuous scan
Each channel with individual result register
Scan on enabled channels
Threshold voltage detection
Conversion start by software programming or
external input
Support PDMA Mode
Other Features
Analog Comparator
Up to two analog comparators
External input or internal bandgap voltage
selectable at negative node
Interrupt when compare result change
Power down wake-up
One built-in temperature sensor with 1
resolution
Brown-Out detector
With 4 levels: 4.5 V/3.8 V/2.7 V/2.2 V
Support Brown-Out Interrupt and Reset option
Other Features
Low Voltage Reset
Keil-ARM Integrated
Development Platform
The programmer can use the Keil IDE to develop
icon
Database
Selection of specific
controller
Click on the + symbol and Select Nuvoton
Startup file
Click on No if prompted for adding the startup
Downloading to Flash
memory
Connect the NUC140 learning board using the
USB cable to the computer. Click on FlashDownload to transfer the program from the PC
to the flash memory of the ARM controller.
//
LED interface
Writing to LCD
//SPI routines are used to pass data to the LCD
// LCD Hardware connections: GPD11- Pin 18 of LCD - SPI data; GPD9 - Pin 21 of
clr_all_pannal();
print_lcd(0, "Welcome to
print_lcd(1, "St.Josephs
");
print_lcd(2, "College of
");
print_lcd(3, "Engineering
while(1);
");
");
END
Prasm2.s
;Add the contents of 32-bit data present in two memory locations Value1 and Value2
;and store the added value in a memory location called Result
;
STOP
ALIGN
Value1 DCD &34567890
Value2 DCD &45455656
AREA
Result DCD 0
END
DATATABLE, DATA,READWRITE
; First location in memory zero offset
;Prasm3.s
;Compute the factorial of a number stored in a memory location Number
;Store the computed factorial in the memory area declared under Result
LDR R0, = Number ; Load the address of Number in R0
LDR R1,[R0]
; Load the number in R1
MOVS R2,R1
; Copy the number to R2
LOOP CMPS R2,#1
; Compare the number in R1 with 1
BEQ SAVE
SUBS R2,R2,#1 ; Subtract the value in R2 with 1 and save in R2
MULS R1,R2,R1 ; Multiply the value in R1 with decremented number in R2.
Store result in R1.
B LOOP
; Continue loop if the value in R1 is not equal to 0
SAVE LDR R5,=Result
STR R1,[R5]
; Store the factorial in the memory (0x20000000)
STOP B STOP
ALIGN
Number DCD 9
;Declare the number whose factorial needs to be computed
AREA DATATABLE, DATA,READWRITE
Result DCD 0
; Memory address is 0x20000000
END
// ANALOG TO DIGITAL CONVERSION : 12-bit ADC value is written into LCD from 0 to 4095
#include <stdio.h>
#include "NUC1xx.h"
#include "LCD_Driver.h
void InitADC(void)
{
/* Step 1. GPIO initial */
GPIOA->OFFD|=0x00800000; //Disable digital input path
SYS->GPAMFP.ADC7_SS21_AD6=1; //Set ADC function
/* Step 2. Enable and Select ADC clock source, and then enable ADC module */
SYSCLK->CLKSEL1.ADC_S = 2; //Select 22Mhz for ADC
SYSCLK->CLKDIV.ADC_N = 1; //ADC clock source = 22Mhz/2 =11Mhz;
SYSCLK->APBCLK.ADC_EN = 1; //Enable clock source
ADC->ADCR.ADEN = 1; //Enable ADC module
/* Step 3. Select Operation mode */
ADC->ADCR.DIFFEN = 0;
//single end input
ADC->ADCR.ADMD = 0;
//single mode
/* Step 4. Select ADC channel */
ADC->ADCHER.CHEN = 0x80;
/* Step 5. Enable ADC interrupt
ADC->ADSR.ADF =1;
//clear the A/D interrupt flags for safe
ADC->ADCR.ADIE = 1;
/* Step 6. Enable WDT module */
ADC->ADCR.ADST=1;
}
*---------------------------------------------------------------------------MAIN function
----------------------------------------------------------------------------*/
int32_t main (void)
{
//Enable 12Mhz and set HCLK->12Mhz
char adc_value[15]="ADC Value:";
UNLOCKREG();
SYSCLK->PWRCON.XTL12M_EN = 1;
SYSCLK->CLKSEL0.HCLK_S = 0;
LOCKREG();
InitADC();
Initial_pannel(); //call initial pannel function
clr_all_pannal();
/* Synch field transmission & Request Identifier Field transmission*/
while(1)
{
while(ADC->ADSR.ADF==0);
ADC->ADSR.ADF=1;
sprintf(adc_value+10,"%d",ADC->ADDR[7].RSLT);
print_lcd(0, adc_value);
Delay(20000);
ADC->ADCR.ADST=1;
}
}