Advertisement
kekellner

Prueba de Structs y Funciones

Mar 11th, 2021
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.52 KB | None | 0 0
  1. /*
  2.  * File:   main.c
  3.  * Author: Kurt
  4.  * Prueba de structs
  5.  * Created on 11 de marzo de 2021, 12:50hrs
  6.  */
  7.  
  8. //------------------------------------------------------------------------------
  9. // Palabra de configuración
  10. //------------------------------------------------------------------------------
  11.  
  12. #pragma config FOSC = EXTRC_NOCLKOUT// Oscillator Selection bits (RCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, RC on RA7/OSC1/CLKIN)
  13. #pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
  14. #pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
  15. #pragma config MCLRE = OFF      // RE3/MCLR pin function select bit (RE3/MCLR pin function is digital input, MCLR internally tied to VDD)
  16. #pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
  17. #pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
  18. #pragma config BOREN = OFF      // Brown Out Reset Selection bits (BOR disabled)
  19. #pragma config IESO = OFF       // Internal External Switchover bit (Internal/External Switchover mode is disabled)
  20. #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
  21. #pragma config LVP = OFF        // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)
  22.  
  23. // CONFIG2
  24. #pragma config BOR4V = BOR40V   // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
  25. #pragma config WRT = OFF        // Flash Program Memory Self Write Enable bits (Write protection off)
  26.  
  27. //------------------------------------------------------------------------------
  28. // Librerías y #defines
  29. //------------------------------------------------------------------------------
  30.  
  31. #define _XTAL_FREQ 8000000
  32.  
  33. #define RS PORTEbits.RE0
  34. #define EN PORTEbits.RE1
  35. #define D0 PORTDbits.RD0
  36. #define D1 PORTDbits.RD1
  37. #define D2 PORTDbits.RD2
  38. #define D3 PORTDbits.RD3
  39. #define D4 PORTDbits.RD4
  40. #define D5 PORTDbits.RB5
  41. #define D6 PORTDbits.RD6
  42. #define D7 PORTDbits.RD7
  43.  
  44. #include <xc.h>
  45. #include <stdint.h>
  46.  
  47.  
  48. //------------------------------------------------------------------------------
  49. // Variables
  50. //------------------------------------------------------------------------------
  51.  
  52. struct carro {
  53.     uint8_t a;
  54.     uint8_t b;
  55. };
  56.  
  57. //------------------------------------------------------------------------------
  58. // Prototipos de funciones
  59. //------------------------------------------------------------------------------
  60. void setup(void);
  61. void funcion(uint8_t var);
  62. uint8_t funcion2(void);
  63.  
  64. //------------------------------------------------------------------------------
  65. // Loop principal
  66. //------------------------------------------------------------------------------
  67. void main(void) {
  68.  
  69.     setup();
  70.     unsigned int a;
  71.  
  72.  
  73.     struct carro STI;
  74.     STI.a = 0xAA;
  75.     STI.b = 0xBB;
  76.    
  77.     funcion(STI.a);
  78.     STI.b = funcion2();
  79.     return;
  80. }
  81.  
  82. //------------------------------------------------------------------------------
  83. // CONFIGURACION
  84. //------------------------------------------------------------------------------
  85.  
  86. void setup(void) {
  87.     ANSEL = 0x00;
  88.     ANSELH = 0x00;
  89.     TRISA = 0x00;
  90.     TRISB = 0x00;
  91.     TRISC = 0x00;
  92.     TRISD = 0x00;
  93.     TRISE = 0x00;
  94.     PORTA = 0x00;
  95.     PORTB = 0x00;
  96.     PORTC = 0x00;
  97.     PORTD = 0x00;
  98.     PORTE = 0x00;
  99. }
  100.  
  101. void funcion (uint8_t var){
  102.     uint8_t c = var;
  103. }
  104.  
  105. uint8_t funcion2(void) {
  106.     return 0xFF;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement