کد تمرین.docx

  • Uploaded by: katayoun
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View کد تمرین.docx as PDF for free.

More details

  • Words: 214
  • Pages: 3
#include “LPC17xx.h” #define rs 0x2 #define en 0x1 unsigned int read_adc(void){ unsigned int i; LPC_ADC -> ADCR |= 0x01000000; do{ i = LPC_ADC -> ADDR0; } while (( i & 0x80000000 ) == 0); return ( i >> 4) & 0x03ff; }

void delay (unsigned int i){ while ( i --); } Void command ( unsigned char i){ LPC_GPIO1 -> FIOCLR |= 0xffffff00; LPC_GPIO1 -> FIOSET | = ( i << 20); LPC_GPIO1 -> FIOCLR = rs; LPC_GPIO1 -> FIOSET = en; delay ( 100000); LPC_GPIO1 -> FIOCLR = en; }

Void command ( unsigned char i){ LPC_GPIO1 -> FIOCLR | = 0xffffff00; LPC_GPIO1 -> FIOSET | = ( i << 20); LPC_GPIO1 -> FIOSET = rs; LPC_GPIO1 -> FIOSET = en; delay ( 100000); LPC_GPIO1 -> FIOCLR = en; } main (void){

unsigned int value , value_1, value_10; LPC_SC -> PCONP = | ( 1 << 12); LPC_PINCON -> PINSEL1 | = (1 << 14);

LPC_ADC -> ADCR = 0x00200301; LPC_GPIO0 ->FIODIR | = 0x000000ff; LPC_GPIO1 ->FIODIR | = 0x00000003; command(0x38); delay(100000); command (0x0e); delay(100000); command(0x01); delay(100000); command(0x80);

delay( 100000); data( ‘T’); delay(100000); data(‘:’); delay(100000); while(1) { value = read_adc(); value = value /12; value_10 = value /10; value_1 = value – ( value_10 * 10); command(0x82); delay(100000); data(value_10); delay(100000); data(value_1); delay(100000); }}

Related Documents

?.docx
May 2020 65
'.docx
April 2020 64
+.docx
April 2020 67
________.docx
April 2020 65
Docx
October 2019 42

More Documents from ""

Emg.docx
April 2020 0
Proj2.pdf
April 2020 1
Rbtak2.docx
April 2020 0
Yhy
October 2019 2
April 2020 4