I'm having problems with the below code. It is written for a 16F1829. It is a stripped down version of what I want. I am guesssing the problem is with not disabling something analog or the pull ups not working right. I have tried adding 4.7k external pull up resistors on both B4 and B5 to 5 volts as well. This is the first time I have tried using this part.
Code:
asm
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_OFF & _MCLRE_OFF & _IESO_OFF
__CONFIG _CONFIG2, _PLLEN_ON & _LVP_OFF & _STVREN_OFF
endasm
Clear
define OSC 32
OSCCON = %11110000 '32 MHz internal
ANSELA = 0 'set porta to digital
ANSELB = 0
ANSELC = 0
OPTION_REG.7 = 0 'enable weak pullups
WPUB = %00110000
INLVLB = 0
CM1CON0.7 = 0 'disable comparator
CM2CON0.7 = 0
TRISA = %011000 '0-2 tx pins
TRISB = %11001111 'red and green
TRISC = %11111111 '
Red var PORTB.5
Green var PORTB.4
PORTA = %000111
PORTB = 0
PORTC = 0
Pause 1000
mainloop:
green = 1
red = 0
pause 1000
green = 0
red = 1
pause 1000
goto mainloop
end
The basic program toggles a red and green line, one high and one low. If I comment out both green or both red lines the program behaves exactly as desired, with the un-commented line going on and off. When both red and green are in the code then the green light remains on and the red light will toggle. I have tried to look for every register I can find in the datasheet that may have anything to to with this, but no luck. I have also pulled the legs up from the circuit and checked with a volt meter just to make sure there aren't any physical problems with the board. I have also use multiple chips.
thanks in advance for the help.
Bookmarks