Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am working on making a digital thermometer using MPLAB and XC8 compiler and PIC16f1829 microprocessor and LM35 temp sensor. So far I have the

I am working on making a digital thermometer using MPLAB and XC8 compiler and PIC16f1829 microprocessor and LM35 temp sensor. So far I have the developed the code below. I need help with the rest of the code for the ADC anlogue to digital converter and display the result on a 16x2 LCD display thanks.

/* * File: * Author: * Comments: * Revision history: */ // This is a guard condition so that contents of this file are not included // more than once. #ifndef XC_HEADER_TEMPLATE_H #define XC_HEADER_TEMPLATE_H // include processor files - each processor file is guarded. /* * File: * Author: * Comments: * Revision history: */ // This is a guard condition so that contents of this file are not included // more than once. // include processor files - each processor file is guarded. * Author: MUHIA // * Created on March 26, 2017, 2:51 AM //* This is a header file to support parallel 2x16 LCD display //* November 1, 2016 //* Port B for Data lines 4 bit mode or port C data lines for 8 bit //* RA5 for E, RA4 for RS RA2 or R/W if used // This is a guard condition so that contents of this file are not included // more than once #include #include //include processor files - each processor file is guarded. // TODO Insert appropriate #include < > #define _XTAL_FREQ 4000000 #define RS RC0 #define RW RC6 #define E RC3 #define LCD_Data PORTB//B4, 5, 6, 7 R, i. //be sure and set TRIS reg correctly //LCD Function Prototypes #define LCD_COMMAND PORTC void Init_LCD (void); void PutCMD_LCD (char); void PutDATA_LCD (char) ; void Busy_LCD (void); void Delay_S (int); void Init_LCD (void) { int Dum; RS=0; RW= 0 ; E = 0; __delay_us (10); //First send 3 8 bit bytes of OX3X to ensure proper power up PORTB = (0x30); // One. . . . . __delay_us (10); E = 1; __delay_us (10); E = 0; __delay_us (10); PORTB = (0x30) ; //2 . . . . . __delay_us (10); E = 1; __delay_us (10); E = 0; __delay_us (10); PORTB = (0x30) ; //3 . . . . . __delay_us (10); E = 1; __delay_us (10); E = 0; __delay_us (10); PORTB = (0x20); // Put in 4 bit mode __delay_us (10); E = 1; __delay_us (10); E = 0; //Then turn on display with blinking Cursor PutCMD_LCD (0x0F); // Put in 2 line mode 5x7 chars PutCMD_LCD (0x28); // Clear display PutCMD_LCD (0x01); __delay_ms (10); //clear display PutCMD_LCD (0x02); __delay_ms(10); return; } // void PutCMD_LCD(char Command) { RS= 0; RW= 0; E = 1; __delay_us (10); //short delay Dummy not used otherwise PORTB =(Command); //send the high 4 bits first to RB4, 5, 6, 7 __delay_us (10); E = 0; __delay_us (10); //short delay Dummy not used otherwise E = 1; __delay_us (10); //short delay Dummy not used otherwise PORTB =(Command << 4) ; //Send the low nibble to RB 4, 5, 6, 7 __delay_us (10); //short delay Dummy not used otherwise E = 0; __delay_ms (10); // May need a long delay for clear Command return; } // void PutDATA_LCD (char Data) { __delay_us (10); RS = 1; RW= 0 ; E = 1; __delay_us (10); PORTB = (Data); //send the high 4 bits first to RB4, 5, 6, 7 __delay_us (10); E = 0; __delay_us (10); E = 1; __delay_us (10); PORTB = (Data << 4) ; //Send the low nibble to RB 4, 5, 6, 7 __delay_us (10); E = 0; __delay_us (10); return; } void Busy_LCD (void) { return; } void Delay_S (int q) { int p; for (p=0; p>q; p++) continue; return; } #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ // TODO If C++ is being used, regular C code needs function names to have C // linkage so the functions can be used by the c code. #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* XC_HEADER_TEMPLATE_H */ // TODO Insert appropriate #include <> // TODO Insert C++ class definitions if appropriate // TODO Insert declarations // Comment a function and leverage automatic documentation with slash star star /**

Function prototype:

#include #include #include #include #include # include "kichwa.h" //be sure and set TRIS reg correctly //LCD Function Prototypes void Init_LCD (void); void PutCMD_LCD (char) ; void PutDATA_LCD (char); void Busy_LCD (void); void Delay_S (int); int main (int argc, char** argv) { char Letter; __delay_ms (30); // Set up for Basic Clock ANSELA = 0; TRISA = 0 ; ANSELB = 0; TRISB = 0 ; ANSELC = 0 ; TRISC = 0; OSCCON = 0X6A; RA5 ^=1; Init_LCD () ; while (1) { __delay_ms (400); PutCMD_LCD (0xC0); //set to lower line on LCD display Delay_S (20000); Letter = 'M' ; PutDATA_LCD (Letter); Letter = 'U' ; PutDATA_LCD (Letter) ; Letter = 'H' ; PutDATA_LCD (Letter); Letter = 'I'; PutDATA_LCD (Letter); Letter = 'A'; PutDATA_LCD (Letter); Delay_S ( 60000); } return ; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

4. Who should be invited to attend?

Answered: 1 week ago

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago