Advertisement
Guest User

Untitled

a guest
May 11th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* ========================================
  2.  *
  3.  * Copyright YOUR COMPANY, THE YEAR
  4.  * All Rights Reserved
  5.  * UNPUBLISHED, LICENSED SOFTWARE.
  6.  *
  7.  * CONFIDENTIAL AND PROPRIETARY INFORMATION
  8.  * WHICH IS THE PROPERTY OF your company.
  9.  *
  10.  * ========================================
  11. */
  12. #include "project.h"
  13. #include "stdio.h"
  14. #include <math.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <tm1637.h>
  18.  
  19. int main(void)
  20. {
  21.    ADC_Start();
  22.    UART_Start();
  23.  
  24.  
  25.  
  26.  
  27.  
  28. int x, y, a ,b , c ;
  29. char string[30];
  30.  
  31.  
  32.    
  33.  
  34.  
  35.     CyGlobalIntEnable; /* Enable global interrupts. */
  36.  
  37.     /* Place your initialization/startup code here (e.g. MyInst_Start()) */
  38.  
  39.     for(;;)
  40.     {
  41.          
  42.      
  43.           ADC_StartConvert();
  44.  
  45.        ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);
  46.        
  47.             x=ADC_GetResult16(0);
  48.         int y=ADC_CountsTo_Volts(0,x);
  49.       sprintf(string,"%d\n",x);
  50.         a=(x*5)/127;
  51.  
  52. CyDelay(50);
  53. b=x-(a*100) / 10 ;
  54. CyDelay(50);
  55. c= x-(a*100) - (x*10);
  56. CyDelay(50);
  57.    
  58.    
  59.    
  60.      UART_PutString(string);
  61.         TM1637_clear();
  62.        TM1637_init(1,1);
  63.     TM1637_display_digit(2,a);
  64.     TM1637_display_segments(3, 0b00111110);
  65.      
  66.    
  67.    
  68.    
  69.  
  70.    
  71.        
  72.  
  73.        
  74.      
  75.        
  76.         CyDelay(250);
  77.         /* Place your application code here. */
  78.     }
  79. }
  80.  
  81. /* [] END OF FILE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement