PDA

View Full Version : Too many error !!



Johan
- 30th June 2007, 12:15
I just got a 18F4431 from a friend.
I tried to make led blink, with following code , but the only LED that turn on/off is the LED on RB0, why ?



OSCCON = $60 ' Internal oscillator frequency 4 Mhz

TRISA = %11111111 ' Set PORTA to all input
TRISB = %00000000 ' Set PORTB to all output
TRISC = %00000000 ' Set PORTC to all input
TRISD = %00000000 ' Set PORTD to all output
TRISE = %00000000 ' Set PORTE to all output

ANSEL0= %00000000 ' Analog channel AN0-AN7 off
ANSEL1= %00000000 ' Analog channel AN8 off

PORTA = 0
PORTB = 0
PORTC = 0
PORTD = 0
PORTE = 0
CLear

main:

high PORTB
pause 1000
LOW PORTB
pause 1000
HIGH PORTC
pause 1000
LOW PORTC
pause 1000
high PORTD
pause 1000
low PORTD
pause 1000
high PORTE
pause 1000
LOW PORTE
pause 1000

end

Bruce
- 30th June 2007, 13:19
HIGH & LOW work with a "pin". Not a whole port. Try PORTB = %01010101 or
some other 8-bit value to write to all 8-bits of a port at once.

If using HIGH or LOW, then use a port 'bit' like HIGH PORTB.0, PORTB.1, etc.

Johan
- 30th June 2007, 14:33
Thank you Bruce,
Yes, now it works :)

I am a beginner with PBP,and I learn fast by making mistakes :)
Now I will try to put some character on LCD