Skip to content

Instantly share code, notes, and snippets.

View giljr's full-sized avatar
💭
Full Stack Developer with a degree in Computer Engineering.

Gilberto Oliveira Jr giljr

💭
Full Stack Developer with a degree in Computer Engineering.
View GitHub Profile
void EEPROM_Write_byte(unsigned char address, unsigned char dta)
{
char STATUS_GIE = 0;
EEADR = address; // Where EEPROM lives
EEDATA = dta; // Byte to be saved
EECON1.EEPGD = 0; // EEPROM memory pointer
EECON1.CFGS = 0; // EEPROM access control
EECON1.WREN = 1; // EEPROM enable
STATUS_GIE = INTCON.GIEH;
INTCON.GIEH = 0;
void EEPROM_Write_byte(unsigned char address, unsigned char dta)
{
char STATUS_GIE = 0;
EEADR = address; // Address to be read
EEDATA = dta; // Byte to print
EECON1.EEPGD = 0; // EEPROM memory pointer
EECON1.CFGS = 0; // EEPROM Control access
EECON1.WREN = 1; // EEPROM enable
STATUS_GIE = INTCON.GIEH;
INTCON.GIEH = 0;
/* Project: Unit 05 - INT
Code: unit_05_06_IOC.c
Objective: This is the Hello World for IOC - Interrupt-on-Change:D
When user presses PORTD.RB4 the LED's at PORTD.RB0 will change for
both rising and falling edge(press, hold and release to see effect)
PORTD.RB1 is blinking by the polling tecnique.
Try to desable the IOC patch -> everything will stop working:/
PORTB Interrupt-on-Change:
An input change on PORTB<7:4> sets flag bit, RBIF
/* Project: Unit 05 - INT
Code: unit_05_05_INT0_INT1_INT2.c
Objective: In this project let's use INT0, INT1& INT2 INTERRUPTIONS, all together:
By pressing PORTB.RB0(INT0) an LED(PORTD.RD4) will light up \o/
By pressing PORTB.RB1(INT1) an LED(PORTD.RD5) will light up \o/
By pressing PORTB.RB2(INT2) an LED(PORTD.RD6) will light up \o/
All external interrupts (INT0, INT1 and INT2)
can wakeup the processor from Idle or Sleep modes "/
/* Project: Unit 05 - INT
Code: unit_05_05_INT0_INT1_INT2.c
Objective: In this project let's use INT0, INT1& INT2 INTERRUPTIONS, all together:
By pressing PORTB.RB0(INT0) an LED(PORTD.RD4) will light up \o/
By pressing PORTB.RB1(INT1) an LED(PORTD.RD5) will light up \o/
By pressing PORTB.RB2(INT2) an LED(PORTD.RD6) will light up \o/
All external interrupts (INT0, INT1 and INT2)
can wakeup the processor from Idle or Sleep modes "/
/* Project: Unit 05 - INT
Code: unit_05_04_INT0.c
Objective: In this project let's use INT0 INTERRUPTION: By pressing
PORTB.RB0(INT0) an LED(PORTD.RD4) will light up \o/
All external interrupts (INT0, INT1 and INT2)
can wakeup the processor from Idle or Sleep modes "/
Author: microgenios, edited by J3
/* Project: Unit 05 - INT
Code: unit_05_03_adcInterruption.c
Objective: In this project let's use INTERRUPTION:
Read 20 sample form ADC and present the arithmetic result in the LCD.
At the end of the conversion, then the Interrupt Indicator Flag will be set (ADIF).
            Consequently, as soon as it is set, the program will be diverted
            for an interrupt routine. (formerly void interrupt_low ())
            In this routine we should do the ADC readings and
            store the values in a buffer in an amount
/* Project: Unit 05 - INT
Code: unit_05_02_highLowPrioritiesInterruptions.c
Objective: 2 interruptions & 1 pulling (High and low priorities setups):
By enable High Prior Interruption (TMR4), an LED (connected to PORTD.RD4)
will toggle every 200 ms, while, to comparative purpose,
by using polling technique, another LED (connected to PORTD.RD4)
will toggle every 1s, and again,
by enable Low Prior Interruption (TMR5), an LED (connected to PORTD.RD5)
will toggle every 1000 ms (1000ms/200ms => scaled 5:1)
/* Project: Unit 05 - INT
Code: unit_05_01_blinkInterruption.c
Objective: This is Interruption Hello World (blinking LEDs)!
By enable interruption, an LED (connected to PORTD.RD0)
will toggle every 200 ms, while, to comparative purpose,
by using polling technique, another LED (connected to PORTD.RD1)
will toggle every 1s (1000ms/200ms => scaled 5:1).
See Calculation memory below:)
/*
* Project name:
unid_04_09_timer0_50ms.c ([email protected])
* Copyright:
(c) J3, Oct 2019
* Revision History:
V 1.0
Initial compilation
* Status:
100% completed