Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.c
- * Author: Kurt
- * Prueba de structs
- * Created on 11 de marzo de 2021, 12:50hrs
- */
- //------------------------------------------------------------------------------
- // Palabra de configuración
- //------------------------------------------------------------------------------
- #pragma config FOSC = EXTRC_NOCLKOUT// Oscillator Selection bits (RCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, RC on RA7/OSC1/CLKIN)
- #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
- #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
- #pragma config MCLRE = OFF // RE3/MCLR pin function select bit (RE3/MCLR pin function is digital input, MCLR internally tied to VDD)
- #pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
- #pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
- #pragma config BOREN = OFF // Brown Out Reset Selection bits (BOR disabled)
- #pragma config IESO = OFF // Internal External Switchover bit (Internal/External Switchover mode is disabled)
- #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
- #pragma config LVP = OFF // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)
- // CONFIG2
- #pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
- #pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off)
- //------------------------------------------------------------------------------
- // Librerías y #defines
- //------------------------------------------------------------------------------
- #define _XTAL_FREQ 8000000
- #define RS PORTEbits.RE0
- #define EN PORTEbits.RE1
- #define D0 PORTDbits.RD0
- #define D1 PORTDbits.RD1
- #define D2 PORTDbits.RD2
- #define D3 PORTDbits.RD3
- #define D4 PORTDbits.RD4
- #define D5 PORTDbits.RB5
- #define D6 PORTDbits.RD6
- #define D7 PORTDbits.RD7
- #include <xc.h>
- #include <stdint.h>
- //------------------------------------------------------------------------------
- // Variables
- //------------------------------------------------------------------------------
- struct carro {
- uint8_t a;
- uint8_t b;
- };
- //------------------------------------------------------------------------------
- // Prototipos de funciones
- //------------------------------------------------------------------------------
- void setup(void);
- void funcion(uint8_t var);
- uint8_t funcion2(void);
- //------------------------------------------------------------------------------
- // Loop principal
- //------------------------------------------------------------------------------
- void main(void) {
- setup();
- unsigned int a;
- struct carro STI;
- STI.a = 0xAA;
- STI.b = 0xBB;
- funcion(STI.a);
- STI.b = funcion2();
- return;
- }
- //------------------------------------------------------------------------------
- // CONFIGURACION
- //------------------------------------------------------------------------------
- void setup(void) {
- ANSEL = 0x00;
- ANSELH = 0x00;
- TRISA = 0x00;
- TRISB = 0x00;
- TRISC = 0x00;
- TRISD = 0x00;
- TRISE = 0x00;
- PORTA = 0x00;
- PORTB = 0x00;
- PORTC = 0x00;
- PORTD = 0x00;
- PORTE = 0x00;
- }
- void funcion (uint8_t var){
- uint8_t c = var;
- }
- uint8_t funcion2(void) {
- return 0xFF;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement