anboli
Full Member level 2
- Joined
- Mar 9, 2012
- Messages
- 144
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,298
- Activity points
- 2,513
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 #include <24ep512gu814.h> #include "REGISTERS.h" #include "PORT_BIT.h" #use delay(clock=25M) void main() { TRISA = 0X0603; // 0b00000110 00000011 TRISB = 0XFFD0; //0XFFFF; TRISC = 0X0002; //0X001E; TRISD = 0X0000; TRISE = 0X0048; //0X03FF; TRISF = 0X3000; TRISG = 0X11C0; //0X93C0; TRISH = 0X001D; TRISJ = 0XFFF0; TRISK = 0XE003; ANSELA = 0X0683; ANSELB = 0XFFFF; ANSELC = 0X001E; ANSELD = 0X0000; ANSELE = 0X03FF; ANSELF = 0X3000; ANSELG = 0X93C0; ANSELH = 0X001D; ANSELJ = 0XFFF0; ANSELK = 0XE003; PORTA = 0X0683; PORTB = 0XFFFF; PORTC = 0X001E; PORTD = 0X0000; PORTE = 0X03FF; PORTF = 0X3000; PORTG = 0X93C0; PORTH = 0X001D; PORTJ = 0XFFF0; PORTK = 0XE003; LATA = 0X0683; LATB = 0XFFFF; LATC = 0X001E; LATD = 0X0000; LATE = 0X03FF; LATF = 0X3000; LATG = 0X93C0; LATH = 0X001D; LATJ = 0XFFF0; LATK = 0XE003; while(1) { if(!RA7) RD1 = 1; //PROB else RD1 = 0; if(!RE0) RJ2 = 1; //PROB else RJ2 = 0; if(!RE1) RJ3 = 1; //PROB else RJ3 = 0; if(!RE2) RD5 = 1; //prob else RD5 = 0; if(RE4) RD7 = 1; //prob else RD7 = 0; if(RG15) RC14 = 1; //prob else RC14 = 0; if(RE5) RC13 = 1; //prob else RC13 = 0; if(RE7) RH15 = 1; //prob else RH15 = 0; if(RC2) RD9 = 1; //prob else RD9 = 0; if(RC3) RD8 = 1; //prob else RD8 = 0; if(RC4) RA15 = 1; //prob else RA15 = 0; if(RG9) RA5 = 1; //prob else RA5 = 0; if(RE8) RH11 = 1; //prob else RH11 = 0; if(RE9) RH10 = 1; //prob else RH10 = 0; if(RB5) RF8 = 1; //prob else RF8 = 0; if(RB3) RF3 = 1; //prob else RF3 = 0; if(RB2) RD15 = 1; //prob else RD15 = 0; if(RB1) RD14 = 1; //prob else RD14 = 0; if(RB0) RH7 = 1; //prob else RH7 = 0; } }
PORTA = 0X0683;
PORTB = 0XFFFF;
PORTC = 0X001E;
PORTD = 0X0000;
PORTE = 0X03FF;
PORTF = 0X3000;
PORTG = 0X93C0;
PORTH = 0X001D;
PORTJ = 0XFFF0;
PORTK = 0XE003;
LATA = 0X0683;
LATB = 0XFFFF;
LATC = 0X001E;
LATD = 0X0000;
LATE = 0X03FF;
LATF = 0X3000;
LATG = 0X93C0;
LATH = 0X001D;
LATJ = 0XFFF0;
LATK = 0XE003;
#include <24ep512gu814.h>
#include "REGISTERS.h"
#include "PORT_BIT.h"
#use delay(clock=25M)
void main()
{
OSCCON = 0x2200;
TRISA = 0X0683; // 0b00000110 00000011
TRISB = 0XFFFF; // OLD VALUE// 0XFFFF; // NEW VALUE// 0XFFD0
TRISC = 0X001E; // OLD VALUE// 0X001E; // NEW VALUE// 0X0002
TRISD = 0X0000;
TRISE = 0X03FF; // OLD VALUE// 0X03FF; // NEW VALUE// 0X0048
TRISF = 0X3000;
TRISG = 0X93C0; // OLD VALUE// 0X93C0; // NEW VALUE// 0X11C0
TRISH = 0X001D;
TRISJ = 0XFFF0;
TRISK = 0XE003;
ANSELA = 0X0683;
ANSELB = 0XFFFF;
ANSELC = 0X001E;
ANSELD = 0X0000;
ANSELE = 0X03FF;
ANSELF = 0X3000;
ANSELG = 0X93C0;
ANSELH = 0X001D;
ANSELJ = 0XFFF0;
ANSELK = 0XE003;
AD1CSSH = 0x0000;
AD1CSSL = 0x0000;
CNPUA = 0X0683;
CNPUB = 0XFFFF;
CNPUC = 0X001E;
CNPUD = 0X0000;
CNPUE = 0X03FF;
CNPUF = 0X3000;
CNPUG = 0X93C0;
CNPUH = 0X001D;
CNPUJ = 0XFFF0;
CNPUK = 0XE003;
LATA = 0X0683;
LATB = 0XFFFF;
LATC = 0X001E;
LATD = 0X0000;
LATE = 0X03FF;
LATF = 0X3000;
LATG = 0X93C0;
LATH = 0X001D;
LATJ = 0XFFF0;
LATK = 0XE003;
PORTA = 0X0683;
PORTB = 0XFFFF;
PORTC = 0X001E;
PORTD = 0X0000;
PORTE = 0X03FF;
PORTF = 0X3000;
PORTG = 0X93C0;
PORTH = 0X001D;
PORTJ = 0XFFF0;
PORTK = 0XE003;
while(1)
{
if(!RH0) RD7 = 1;
else RD7 = 0;
if(!RH2) RC14 = 1;
else RC14 = 0;
if(!RH3) RC13 = 1;
else RC13 = 0;
if(!RK15) RA5 = 1;
else RA5 = 0;
if(!RK14) RH11 = 1;
else RH11 = 0;
if(!RK13) RH10 = 1;
else RH10 = 0;
if(!RA1) RF8 = 1;
else RF8 = 0;
if(!RF13) RF3 = 1;
else RF3 = 0;
if(!RF12) RD15 = 1;
else RD15 = 0;
if(!RH4) RJ0 = 1;
else RJ0 = 0;
// following are INPUT PROBLEMS
if(!RB6) RD1 = 1;
else RD1 = 0;
if(!RB7) RJ2 = 1;
else RJ2 = 0;
if(!RA9) RJ3 = 1;
else RJ3 = 0;
if(!RA10) RD5 = 1;
else RD5 = 0;
if(!RB8) RH15 = 1;
else RH15 = 0;
if(!RB9) RD9 = 1;
else RD9 = 0;
if(!RB10) RD8 = 1;
else RD8 = 0;
if(!RB11) RA15 = 1;
else RA15 = 0;
if(!RB12) RD14 = 1;
else RD14 = 0;
if(!RB13) RH7 = 1;
else RH7 = 0;
if(!RB14) RD12 = 1;
else RD12 = 0;
if(!RB15) RD13 = 1;
else RD13 = 0;
}
}
program has simple loops and i guess you no problem with the code!
I cant say the reason try reading port pins like if(PORTBbits.RB6),
and even then if ports aren't reading, try checking with multi-meter if your pins are working on press of a particular switch !
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?