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
/* Project: Unit 10 - 7SEGS
Code: unit_10_2_upDownCounter7segs.c
Objective: This program use interruptions and writes the value of incremented button
on the 7-segment displayCrystal = 8MHz:)
The example program below was compiled on the mikroC compiler (www.mikroe.com)
and aims to write on displays Kit PICGenios Microgens Technology Center.
Note: It does make use of the scanning technique (on-off-on cycle);
all the LEDs stay on for 1ms and we get the impression that
all the LEDs are on at the same time forever;
/* Project: Unit 10 - 7SEGS
Code: unit_10_1_7segsScan.c
Objective: This program use interruption and writes the value 1234 on the 7-segment displayCrystal = 8MHz:)
The example program below was compiled on the mikroC compiler (www.mikroe.com)
and aims to write on displays Kit PICGenios Microgens Technology Center.
Note: It does make use of the scanning technique (on-off-on cycle);
all the LEDs stay on for 1ms and we get the impression that
all the LEDs are on at the same time forever;
This is called Persistence Of Vision - POV :D
/* Project: Unit 10 - 7SEGS
Code: unit_10_0_7segsTest.c
Objective: This program writes the value 1234 on the 7-segment displayCrystal = 8MHz:)
The example program below was compiled on the mikroC compiler (www.mikroe.com)
and aims to write on displays Kit PICGenios Microgens Technology Center.
Note: It does make use of the scanning technique (on-off-on cycle);
all the LEDs stay on for 1ms and we get the impression that
all the LEDs are on at the same time forever;
This is called Persistence Of Vision - POV :D
/* Project: Unit 10 - 7SEGS
Code: unit_10_0_7segsTest.c
Objective: This program writes the value 1234 on the 7-segment displayCrystal = 8MHz:)
The example program below was compiled on the mikroC compiler (www.mikroe.com)
and aims to write on displays Kit PICGenios Microgens Technology Center.
Note: It does make use of the scanning technique (on-off-on cycle);
all the LEDs stay on for 1ms and we get the impression that
all the LEDs are on at the same time forever;
This is called Persistence Of Vision - POV :D
#ifndef _LIB_EEPROM_
#define _LIB_EEPROM_
void EEPROM_Write_byte(unsigned char address, unsigned char dta);
unsigned char EEPROM_Read_byte(unsigned char address);
void EEPROM_Write_int (unsigned char address, unsigned int dta);
unsigned int EEPROM_Read_int (unsigned int address);
void EEPROM_Write_float(unsigned char address,unsigned char *dta);
float EEPROM_Read_float(unsigned char address);
void EEPROM_Write_array (unsigned char address, unsigned char qtd_byte,unsigned char *dta);
void EEPROM_Read_array (unsigned char address, unsigned char qtd_byte,unsigned char *buffer);
#include "lib_eeprom.h"
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
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 "/