midsha1628
New Member
Hello everyone,
Thank you for taking the time to view my first post here on the forum.
I am having a problem with a part of a program I am currently working on which uses the 16hv616. The program uses a data table which only contains 29 values that can be 'looked up'. The program senses an input from a magnetic sensor. Time is measured between pulses from the magnetic sensor and if the time is less than a specific amount of uS. an LED will light stating time is less than my threshold. Now my program simulates fine (I use mplab v8.0 as well as, separately, a spin fixture that simulates the circuit in the actual environment) up to the data table. I have narrowed it down to the point that when it calls the data table, I have tried a 'call' as well as a macro program, it works but after it goes to the data table and reads the "movwf pcl" line it does not work correctly even though it returns the correct value from the table and I have watched it loading the pclath and pcl before and after returning from the 'call' and everything seems fine to me. I have used mplab to step through my program and when I 'call' the table and just place a 'return' inside the table location with nothing else, no movwf pcl, and return from it, the circuit sims and tests fine. But as soon as the 'movwf pcl' is inserted, It seems like the program crashes because the LED does not come on and when the RPM come down to zero the LED that I am using to tell me when a pulse is sensed does not go off(it should when there is no signal). I am thinking that it is somehow loosing it's location when it 'reads the movwf pcl' but am baffled as to how to correct it since it returns the correct value from the table. Ihave listed the code section below. Thank you for any help you can give. I am stumped!
;Main code
MOVLW HIGH (LOOKUP+1)
MOVWF PCLATH
MOVLW LOW (LOOKUP+1)
ADDWF TABLE, W ; 'TABLE' IS REG. WHERE 'JUMP TO' NUMBER IS STORED.
BTFSC STATUS, C
INCF PCLATH, F
CALL LOOKUP
MOVWF TABLE_2 ; 'TABLE_2' IS WHERE RESULT IS STORED.
;----------------------------------------
;MY DATA TABLE
LOOKUP
MOVWF PCL
DT 0X05, 0X53, 0X76, 0X97, 0X99, 0X51, 0X90, 0X64, 0X86, 0X54
DT 0X43, 0X44, 0X79, 0X89, 0X65, 0X56, 0X43, 0X39, 0X77, 0X01
DT 0X10, 0X24, 0X21, 0X88, 0X18, 0X16, 0X47, 0X58, 0X88
Thank you for taking the time to view my first post here on the forum.
I am having a problem with a part of a program I am currently working on which uses the 16hv616. The program uses a data table which only contains 29 values that can be 'looked up'. The program senses an input from a magnetic sensor. Time is measured between pulses from the magnetic sensor and if the time is less than a specific amount of uS. an LED will light stating time is less than my threshold. Now my program simulates fine (I use mplab v8.0 as well as, separately, a spin fixture that simulates the circuit in the actual environment) up to the data table. I have narrowed it down to the point that when it calls the data table, I have tried a 'call' as well as a macro program, it works but after it goes to the data table and reads the "movwf pcl" line it does not work correctly even though it returns the correct value from the table and I have watched it loading the pclath and pcl before and after returning from the 'call' and everything seems fine to me. I have used mplab to step through my program and when I 'call' the table and just place a 'return' inside the table location with nothing else, no movwf pcl, and return from it, the circuit sims and tests fine. But as soon as the 'movwf pcl' is inserted, It seems like the program crashes because the LED does not come on and when the RPM come down to zero the LED that I am using to tell me when a pulse is sensed does not go off(it should when there is no signal). I am thinking that it is somehow loosing it's location when it 'reads the movwf pcl' but am baffled as to how to correct it since it returns the correct value from the table. Ihave listed the code section below. Thank you for any help you can give. I am stumped!
;Main code
MOVLW HIGH (LOOKUP+1)
MOVWF PCLATH
MOVLW LOW (LOOKUP+1)
ADDWF TABLE, W ; 'TABLE' IS REG. WHERE 'JUMP TO' NUMBER IS STORED.
BTFSC STATUS, C
INCF PCLATH, F
CALL LOOKUP
MOVWF TABLE_2 ; 'TABLE_2' IS WHERE RESULT IS STORED.
;----------------------------------------
;MY DATA TABLE
LOOKUP
MOVWF PCL
DT 0X05, 0X53, 0X76, 0X97, 0X99, 0X51, 0X90, 0X64, 0X86, 0X54
DT 0X43, 0X44, 0X79, 0X89, 0X65, 0X56, 0X43, 0X39, 0X77, 0X01
DT 0X10, 0X24, 0X21, 0X88, 0X18, 0X16, 0X47, 0X58, 0X88