This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PIC16F628A Configuration Bit Settings | |
// 'C' source line config statements | |
// CONFIG | |
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN) | |
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) | |
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled) | |
#pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR) | |
#pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PIC18F2550 Configuration Bit Settings | |
// 'C' source line config statements | |
// CONFIG1L | |
#pragma config PLLDIV = 5 // PLL Prescaler Selection bits (Divide by 5 (20 MHz oscillator input)) | |
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2]) | |
#pragma config USBDIV = 1 // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale) | |
// CONFIG1H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned ADC_Read(unsigned short channel) | |
{ | |
ADCON0 &= 0x03; | |
ADCON0 |= (channel << 2); | |
delay_us(30); | |
GO_nDONE = 1; | |
while (GO_nDONE); | |
return ((ADRESH << 8) + ADRESL); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void delay_ms(unsigned int delay) | |
{ | |
for(;delay > 0; delay--) | |
{ | |
__delay_ms(1); | |
} | |
} | |
void delay_us(unsigned int delay) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PIC18F2550 Configuration Bit Settings | |
// 'C' source line config statements | |
// CONFIG1L | |
#pragma config PLLDIV = 12 // PLL Prescaler Selection bits (Divide by 12 (48 MHz oscillator input)) | |
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2]) | |
#pragma config USBDIV = 1 // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
posição_ordenada = 0; | |
while(posição_ordenada != tamanho_do_vetor) | |
{ | |
menor = vetor[posição_ordenada]; | |
posição_do_menor = posição_ordenada; | |
for(i = posição_ordenada+1; i < tamanho_do_vetor; i++) | |
{ | |
if(vetor[i] < menor) | |
{ | |
menor = vetor[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(feito == 0) | |
{ | |
feito = 1; | |
for(i = 0; i < tamanho_do_vetor; i++) | |
{ | |
if(vetor[i] > vetor[i+1]) | |
{ | |
troca(vetor[i], vetor[i+1]); | |
feito = 0; | |
} |