kappa_am
Full Member level 6
- Joined
- Jul 16, 2012
- Messages
- 331
- Helped
- 19
- Reputation
- 38
- Reaction score
- 19
- Trophy points
- 1,298
- Location
- Vancouver
- Activity points
- 3,859
unsigned short PS[3], CH, CHO, CHN, CHZ, DCH, CL[3], IPH[3]={1,1,0}, CL1, PSO1;
void main() {
OPTION_REG=0x87;
INTCON=0x00;
TRISD=0x00;
TRISC=0xFF;
TRISE=0x00;
TRISB=0xFF;
TRISA=0x00;
PORTA=0;
CH=0;
PORTE=0x03;
delay_ms(5000);
while(1) {
CHO=0;
CH=(PORTB & 0x06)>>1;
PORTE=CH+4;
delay_ms(5000);
while(CHO==0) {
if((PORTC & 0x03)==CH) {
CL[0]=PORTC>>2;
PORTE.B2=0;
CHO=1;}}
PORTD=CL[0];
delay_ms(5000);
//////////////////////////
} }
PORTE.B2=0;
//unsigned short PS[3], CH, CHO, CHN, CHZ, DCH, CL[3], IPH[3]={1,1,0}, CL1, PSO1;
const unsigned long temp = 1000;
void main()
{
OPTION_REG=0x87;
ADCON1 = 0x0F;
INTCON=0x00;
TRISA=0x00;
TRISB=0xFF;
TRISC=0xFF;
TRISD=0x00;
TRISE=0x00;
PORTA=0;
PORTB=0;
PORTC=0;
PORTD=0;
PORTE=0x03;
// CH=0;
delay_ms(temp);
while(1)
{
delay_ms(temp);
PORTE.B2=1;
delay_ms(temp);
PORTE.B2=0;
//////////////////////////
}
}
1. nonsense, ADCON is only affecting digital input functionalityBecause is missing ADCON register, make all pins as digital!!!
And maybe by PORTE=CH+4;
4.5 PORTE and TRISE Register
PORTE has three pins (RE0/RD/AN5, RE1/WR/AN6
and RE2/CS/AN7) which are individually configurable
as inputs or outputs. These pins have Schmitt Trigger
input buffers.
The PORTE pins become the I/O control inputs for the
microprocessor port when bit PSPMODE (TRISE<4>) is
set. In this mode, the user must make certain that the
TRISE<2:0> bits are set and that the pins are configured
as digital inputs.[B][COLOR="#0000FF"] Also, ensure that ADCON1 is configured
for digital I/O[/COLOR][/B]. In this mode, the input buffers are
TTL.
unsigned short rep, OUTM[3]={136, 85, 14};
interrupt(void) {
if (INTCON.INTF){
INTCON.INTF=0;
rep=(PORTB & 0x06)>>1;
PORTA=OUTM[rep] & 0x0F;
PORTB=OUTM[rep] & 0xF0;
}}
void main() {
OPTION_REG=0xc7;
ADCON0=0x00;
ADCON1=0x07;
TRISA =0xF0;
TRISB =0x0F;
INTCON=0x90;
PORTA=0x00;
PORTB=0x00;
while(1);
}
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?