Hi All,
I am working on a project, I asked for help with in the projects forum, and consequently have been working on a 3 phase inverter using the PIC18F4431.
This is described in Microchips document A900. I learnt the machine code and went through the code that was provided to make sure I understood it... but it doesn't work. So I thought it best to start with the basics and made an LED flash, and made it flash faster when a button was pressed.. I did it using interrupts, and all is great..
my problem is that I can create a loop that just counts down from 255 to 0 to waste time... but when I copy the loop used in the inverter program (a loop within a loop) the program seems to get caught in an infinite loop, I know this because I turn the LED on before the delay and turn it off after - it never goes off (I have put an oscilloscope on the output to make sure of this)
The WDT is turned off...
The other thing is, the code works fine when I use MPLAB sim...
can anybody see whats wrong?
Cheers
Shaun
MainProg code
Start:
movlw b'11111100'
movwf TRISD
bsf PORTD, 1
;=======================================================================
MainLoop
bsf PORTD, 1
call DELAY
bcf PORTD, 1
call DELAY
goto MainLoop
;=======================================================================
DELAY
movlw 0xFF
movwf COUNTER
loop1
movlw 0xFF
movwf COUNTER1
loop
decfsz COUNTER1, F
goto loop
decfsz COUNTER,1
goto loop1
return
;=======================================================================
I am working on a project, I asked for help with in the projects forum, and consequently have been working on a 3 phase inverter using the PIC18F4431.
This is described in Microchips document A900. I learnt the machine code and went through the code that was provided to make sure I understood it... but it doesn't work. So I thought it best to start with the basics and made an LED flash, and made it flash faster when a button was pressed.. I did it using interrupts, and all is great..
my problem is that I can create a loop that just counts down from 255 to 0 to waste time... but when I copy the loop used in the inverter program (a loop within a loop) the program seems to get caught in an infinite loop, I know this because I turn the LED on before the delay and turn it off after - it never goes off (I have put an oscilloscope on the output to make sure of this)
The WDT is turned off...
The other thing is, the code works fine when I use MPLAB sim...
can anybody see whats wrong?
Cheers
Shaun
MainProg code
Start:
movlw b'11111100'
movwf TRISD
bsf PORTD, 1
;=======================================================================
MainLoop
bsf PORTD, 1
call DELAY
bcf PORTD, 1
call DELAY
goto MainLoop
;=======================================================================
DELAY
movlw 0xFF
movwf COUNTER
loop1
movlw 0xFF
movwf COUNTER1
loop
decfsz COUNTER1, F
goto loop
decfsz COUNTER,1
goto loop1
return
;=======================================================================