C Examples 3. Download Links dsPIC30F4011/4012 Data Sheet dsPIC30F4013/3014 dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.

Slides:



Advertisements
Similar presentations
Lab 1 I/O, timers, interrupts on the eZ430-RF2500 Thomas Watteyne EE290Q – Spring 2010
Advertisements

Mark Neil - Microprocessor Course 1 Device Drivers – Digital Voltmeter.
Chung-Ta King National Tsing Hua University
C Examples 1.
Digital Thermostat and Data Logger Brandon Wagner and David Southwick.
C Examples 4.
1 Lab2: A/D Converter. 2 This circuit connects a variable voltage to an A/D port on the AVR mcu. Your software running on the AVR mcu will read the digital.
PIC16F bit 8-channel Analog-to-Digital Converter.
Aztec PC Scope Preliminary Design Review Fall 2006 Michael MasonJed Brown Andrew YoungsJosh Price.
Railway Foundation Electronic, Electrical and Processor Engineering.
Microcontroller / 8051 family
Robotics Research Laboratory Louisiana State University.
NetBurner MOD 5282 Network Development Kit MCF 5282 Integrated ColdFire 32 bit Microcontoller 2 DB-9 connectors for serial I/O supports: RS-232, RS-485,
Designing with components II
1 Applied Control Systems Technology. 2 Pin configuration Applied Control Systems.
Digilent System Board Capabilities Serial Port (RS-232) Parallel Port 1 Pushbutton Hint: Good for a reset button Connected to a clock input. See Digilent.
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
Embedded System Design Laboratory October 11, 2002Stanford University - EE281 Lecture #4#1 Lecture #4 Outline Announcements Project Proposal AVR Processor.
ELE2MIC Lecture 21 The AVR Sleep Modes ATMEGA128’s Analog to Digital Converter –Features –Block Diagram –Clock Source –Input Sources –Interrupts –BandGap.
Microprocessors A practical approach Subjects Goals for this module Results Subjects of the module Plans Questions.
RS232 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7
1 Lab 1: Introduction. 2 Configure ATMEL AVR Starter Kit 500 (STK500), a prototyping/development board for Lab1. ATmega16 ( V) is the chip used.
Robotics Research Laboratory Louisiana State University.
1 LHO 13 The 8051CF020 and the University Daughter Card.
C Examples 5. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
MICROCONTROLLER SYSTEMS Part 1. Figure 1.1Elements of a digital controller CPU Central Processing Unit Input Peripherals Output Peripherals ROM Read Only.
Atmel Atmega128 Overview ALU Particulars RISC Architecture 133, Mostly single cycle instructions 2 Address instructions (opcode, Rs, Rd, offset) 32x8 Register.
ATMEL AVR 8 bit RISC MICROCONTROLLERS a general comparison.
DsPIC30F4011 Fall DIP Switches  The upper four switches of SW1 are used to enable LEDs connected to PORTB/C, PORTA/D, PORTE and PORTF. For example,
Analog to Digital Converter (ADC). Analog to Digital Converters  Microcontroller understands only digital language.  To convert the analog output from.
Lecture 11: Liquid Level Control System: A Case Study 1.
C Examples 1. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
Device Overview 1.  The advantages of all PIC18Fxxxx microcontrollers:  High computational performance  High-endurance  Enhanced Flash program memory.
C Examples 1. Download Links dsPIC30F4011/4012 Data Sheet dsPIC30F4013/3014 dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
Computer Science Summer term 2012 Final Project Team 2.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
Analog to Digital Conversion - ADC Mark Neil - Microprocessor Course 1 Device Drivers – Measuring Voltages.
PIC16F887.
C Examples 6. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
Microcontrollers JULES CALELLA. Microcontrollers vs Microprocessors  Microprocessors – do not contain RAM, ROM, I/O  Microcontrollers – The whole package.
Introduction to Projects using Microcontroller Md. Khalilur Rhaman Credit: Interface Lab.
1 Lab 4: D/A Converter Lab 4: D/A Converter This is a simple resistive network for a D/A converter Port 1, Port 0 are digital inputs ==> 00 (minimum),
Microprocessors A practical approach..
Sitarambhai Naranjibhai Patel Institute of Technology and Research Centre, Umrakh, Bardoli. A Presentation On “ 16x2 LCD Interfacing with AVR atmega32.
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
C Examples 3. Download Links dsPIC30F4011/4012 Data Sheet dsPIC30F4013/3014 dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
 Mini-Computer ◦ Microprocessor  The Brains  Arithmetic Logic Unit (ALU)  Control Unit  Program/ Data Storage  Peripherals (Input/Output)  Low-Cost.
Chip Config & Drivers – Required Drivers:
Servos Elementary Robotics with Servos
CS4101 嵌入式系統概論 General Purpose IO
Lecture 8: TI MSP430 Interrupts, ISRs
4-Integrating Peripherals in Embedded Systems (cont.)
UNIVERSAL COLLEGE OF ENGINEERING & TECHNOLOGY
EECE.3170 Microprocessor Systems Design I
CS4101 嵌入式系統概論 General Purpose IO
The Arduino Microcontroller: Atmel AVR Atmega 328
8051 Programming in C rhussin.
I/O Ports in AVR Sepehr Naimi
Chapter 10 It’s an Analog World
I/O Ports in AVR Sepehr Naimi
ADC and DAC Programming in AVR
MSP432™ MCUs Training Part 6: Analog Peripherals
Pondicherry Engineering College
8051 Micro Controller.
輸出動作與輸入命令相同.
Prof. Chung-Ta King Department of Computer Science
TI LaunchPad I/O Programming with Energia
PIC16F887.  1.Microcontroller introducton  2.MPLAB,Hi-tech compilers  3.LED  4.Switches/push buttons  5.7-Segment Display  6.Keypad  7.LCD  8.Timers.
ECE 3567 Microcontroller Lab
Presentation transcript:

C Examples 3

Download Links dsPIC30F4011/4012 Data Sheet dsPIC30F4013/3014 dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference

Key DEBOUNCING

Key DEBOUNCING – 3 (SWITCH4B) void main() { int start = 0; ADPCFG = 0xFFFF; TRISB=0b ; PORTB=0x0000; TRISF=0b000001; PORTF=0x0000; while(1) { Delay_ms(5000); // LONG DELAY IMPAIRS SWITCH OPERATION PORTB=~PORTB; // LED FLASHING if (Button(&PORTF, 0, 1, 1)) // Switch at PORTF Bit 0 start = 1; if (start&&Button(&PORTF, 0, 1, 0)) // Switch at PORTF Bit 0 { start=0; PORTF.F1=PORTF.F1^1; // Toggles PORTF Bit 1 }

Key DEBOUNCING – 4 (SWITCH5B) void main () { int start=0; T2CON=0b ; // Enable Timer 2/3, Prescaler =1 IEC0=0x0080; // Enable Interrupt for Timer 3 PR2=0xE100; // (PR3PR2)BASE16 = (100,000,000)BASE10 PR3=0x05F5; ADPCFG = 0xFFFF; TRISB=0b ; PORTB=0x0000; TRISF=0b000001; PORTF=0x0000; while(1) { if (Button(&PORTF, 0, 1, 1)) // Switch at PORTF Bit 0 start = 1; if (start&&Button(&PORTF, 0, 1, 0)) // Switch at PORTF Bit 0 { start=0; PORTF.F1=PORTF.F1^1; // Toggles PORTF Bit 1 } void interrupt_T2() org 0x { PORTB=PORTB^0x02; IFS0=0x0000; }

UART1 U1MODE = 0x8400;

UART1 unsigned char uc1, rx1; void main() { ADPCFG=0xFFFF; // Starts UART Uart1_Init(19200); // U1MODE = 0x8400; // This instruction required if using alternate pinout delay_ms(200); TRISB=0x0000; PORTB=0xFFFF; Uart1_Write_Char('a'); while(1) { if (Uart1_Data_Ready()) { rx1 = Uart1_Read_Char(); Uart1_Write_Char(++rx1); PORTB=~PORTB; } }//~!

UART2B-EEL unsigned adcRes; char txt[6]; void main() { int i; PORTB = 0x0000; TRISB.F1 = 1; // set pin as input - needed for ADC to work Uart1_Init(19200); while (1) { adcRes = Adc_Read(1); // Read ADC channel 1 WordToStr(adcRes, txt); // Convert ADC value to text i=0; while (txt[i]) { Uart1_Write_Char(txt[i]); // Send text to UART one character at a time i=i+1; Delay_ms(1000); } }//~!

UART2B-CPE unsigned adcRes; char txt[6]; void Uart1_Write_Text(char *txt_to_wr) { while (*txt_to_wr) Uart1_Write_Char(*(txt_to_wr++)); } void main() { PORTB = 0x0000; TRISB.F1 = 1; // set pin as input - needed for ADC to work Uart1_Init(19200); while (1) { adcRes = Adc_Read(1); WordToStr(adcRes, txt); Uart1_Write_Text(txt); Delay_ms(1000); } }//~!

The Family reference manual shows the connection in red, it does not show the direct connection to VREF-

Sampling Time To minimize the effects of pin leakage currents on the accuracy of the A/D converter, the maximum recommended source impedance, RS, is 5 kΩ for the conversion rates of up to 500 ksps and a maximum of 500Ω for conversion rates of up to 1 Msps