i just want to activate the port and just to blink the LED ,How to activate internal oscillator iam using Micro C pro v-5.6.1
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 void main() { TRISB=0; while(1) { PORTB.RB7=1; delay_ms(500); PORTB.RB7=0; delay_ms(500); } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 void main() { TRISA=1; TRIS B=0; OSCCON = 0b01101111; while(1) { if(PORTA.RA1==1)// if RA1 is high then RB7 should glow { PORTB.RB7=1; } else { PORTB.RB7=0; } } }
void main() {
TRISA = 0x02;
TRISB = 0x00;
PORTB = 0x00;
ADCON1 = 0b00001111;
CMCON = 0x07;
while(1) {
if(PORTA.F1 == 1) {
Delay_ms(30);
if(PORTA.F1 == 1) {
PORTB.F7 = 1;
}
else {
PORTB.F7 = 0;
}
}
}
}
I make it my standard practice to always use binary for TRIS and other registers that have a bit format. Saves no end of confusion, and I'm easily confused!You have set TRISA = 1; It should be 0x02; You are using RA1 so it is 00000010 which is 0x02.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 void main() { TRISA = 0x02; TRISB = 0x00; PORTB = 0x00; ADCON1 = 0b00001111; CMCON = 0x07; OSCCON=0B01101111; while(1) { if(PORTA.F1 == 1) { Delay_ms(10); if(PORTA.F1 == 1) { PORTB.F7 = 1; } } else if(PORTA.F2==1){ Delay_ms(10); if(PORTA.F2==1){ PORTB.F6=1; } else { PORTB=0; } } } }
void main() {
TRISA = 0b01111111;
TRISB = 0b00000000;
PORTB = 0b00000000;
ADCON1 = 0b00001111;
CMCON = 0b00000111;
while(1) {
if(PORTA.F0 == 1) {
Delay_ms(30);
if(PORTA.F0 == 1) {
PORTB.F0 = 1;
}
}
if(PORTA.F1 == 1) {
Delay_ms(30);
if(PORTA.F1 == 1) {
PORTB.F1 = 1;
}
}
if(PORTA.F2 == 1) {
Delay_ms(30);
if(PORTA.F2 == 1) {
PORTB.F2 = 1;
}
}
if(PORTA.F3 == 1) {
Delay_ms(30);
if(PORTA.F3 == 1) {
PORTB.F3 = 1;
}
}
if(PORTA.F4 == 1) {
Delay_ms(30);
if(PORTA.F4 == 1) {
PORTB.F4 = 1;
}
}
if(PORTA.F5 == 1) {
Delay_ms(30);
if(PORTA.F5 == 1) {
PORTB.F5 = 1;
}
}
if(PORTA.F6 == 1) {
Delay_ms(30);
if(PORTA.F6 == 1) {
PORTB.F0 = 0;
PORTB.F1 = 0;
PORTB.F2 = 0;
PORTB.F3 = 0;
PORTB.F4 = 0;
PORTB.F5 = 0;
}
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?