Advertisement
Andrea_Grosso

PIC16F15313

Mar 6th, 2021
1,236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.40 KB | None | 0 0
  1. /**
  2.   Generated Main Source File
  3.  
  4.   Company:
  5.     Microchip Technology Inc.
  6.  
  7.   File Name:
  8.     main.c
  9.  
  10.   Summary:
  11.     This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
  12.  
  13.   Description:
  14.     This header file provides implementations for driver APIs for all modules selected in the GUI.
  15.     Generation Information :
  16.         Product Revision  :  PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7
  17.         Device            :  PIC16F15313
  18.         Driver Version    :  2.00
  19. */
  20.  
  21. /*
  22.     (c) 2018 Microchip Technology Inc. and its subsidiaries.
  23.    
  24.     Subject to your compliance with these terms, you may use Microchip software and any
  25.     derivatives exclusively with Microchip products. It is your responsibility to comply with third party
  26.     license terms applicable to your use of third party software (including open source software) that
  27.     may accompany Microchip software.
  28.    
  29.     THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
  30.     EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
  31.     IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
  32.     FOR A PARTICULAR PURPOSE.
  33.    
  34.     IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
  35.     INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
  36.     WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
  37.     HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
  38.     THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
  39.     CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
  40.     OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
  41.     SOFTWARE.
  42. */
  43.  
  44. #include "mcc_generated_files/mcc.h"
  45.  
  46. /*
  47.                          Main application
  48.  */
  49. /*Funzioni*/
  50.    int Temperatura(void) {
  51.        unsigned short Val_camp;
  52.        int T;
  53.        int V;
  54.        ADC_SelectChannel(Temp);
  55.        ADC_StartConversion();
  56.        ADC_IsConversionDone();
  57.        ADC_GetConversionResult();
  58.        Val_camp = ADC_GetConversion(Temp);
  59.        ADC_TemperatureAcquisitionDelay();
  60.        V = ((Val_camp*5000)/1024);
  61.        T = ((V-500)/10);
  62.        return T;
  63.    }
  64. void main(void)
  65. {
  66.     // initialize the device
  67.     SYSTEM_Initialize();
  68.     ADC_Initialize();
  69.     // When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
  70.     // Use the following macros to:
  71.  
  72.     // Enable the Global Interrupts
  73.     //INTERRUPT_GlobalInterruptEnable();
  74.  
  75.     // Enable the Peripheral Interrupts
  76.     //INTERRUPT_PeripheralInterruptEnable();
  77.  
  78.     // Disable the Global Interrupts
  79.     //INTERRUPT_GlobalInterruptDisable();
  80.  
  81.     // Disable the Peripheral Interrupts
  82.     //INTERRUPT_PeripheralInterruptDisable();                                                      
  83.     Led_SetHigh();                                                              /* Testo il led per 10 sec */
  84.     __delay_ms(10000);
  85.     Led_SetLow();
  86.     while (1)
  87.     {
  88.         // Add your application code
  89.         if (Temperatura() > 25)  {                                              /* Temperatura maggiore di 25 */
  90.             Led_SetHigh();
  91.             __delay_ms(10000);                                                  /* Led per 10 secondi ON */
  92.             Led_SetLow();
  93.         }
  94.         else __delay_ms(2000);  
  95.     }
  96.     PIN_MANAGER_IOC();
  97. }  
  98.    
  99. /**
  100.  End of File
  101. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement