Maker Pro
Maker Pro

16f628a code bug

Hello, I am using an older PIC 16f628 microcontroller to generate sine
waves using a lookup table to calculate the sine function, and I want
to use the 16f628a instead, but the lookup table function is
mysteriously being called with excessively large w register values that
overrun the end of the table causing glitches in the waveform. Is it
possible that since my table is located at address 0x02 (I think) that
something like an interrupt could be occurring unexpectedly that enters
the table? I do not have problems with any other programs on these new
chips, only when I try to use a lookup table. And I have positioned the
table between program memory boundaries.

Thanks,
jan
 
S

Spehro Pefhany

Jan 1, 1970
0
Hello, I am using an older PIC 16f628 microcontroller to generate sine
waves using a lookup table to calculate the sine function, and I want
to use the 16f628a instead, but the lookup table function is
mysteriously being called with excessively large w register values that
overrun the end of the table causing glitches in the waveform. Is it
possible that since my table is located at address 0x02 (I think) that
something like an interrupt could be occurring unexpectedly that enters
the table? I do not have problems with any other programs on these new
chips, only when I try to use a lookup table. And I have positioned the
table between program memory boundaries.

Thanks,
jan

See document DS40048A for migration information.


Best regards,
Spehro Pefhany
 
L

Luhan Monat

Jan 1, 1970
0
Hello, I am using an older PIC 16f628 microcontroller to generate sine
waves using a lookup table to calculate the sine function, and I want
to use the 16f628a instead, but the lookup table function is
mysteriously being called with excessively large w register values that
overrun the end of the table causing glitches in the waveform. Is it
possible that since my table is located at address 0x02 (I think) that
something like an interrupt could be occurring unexpectedly that enters
the table? I do not have problems with any other programs on these new
chips, only when I try to use a lookup table. And I have positioned the
table between program memory boundaries.

Thanks,
jan
Hi,

The interrupt for that chip is at location 4. An iterrupt to that
address would not 'glitch' the sinewave - it would crash the system.

If you post your code here, I'll be glad to look it over.
 
Thanks guys,
I added a couple lines of code to process any interrupt that could
occur (org 0x04 ; retfie), and made sure that the compiler was set to
the "a" version chip and it worked great. I don't know why the simple
code was causing an interrupt on the new chip though.

Jan
 
Top