Hello all.
I ran across an odd problem that maybe some of you can help with.
Just for a "see how long it takes" experiment I programmed a 28X1 to find prime numbers between 3 and 65535. It took a few hours to find them so naturally I tried to find ways to speed things up so I added about 80 IF-THEN statements to factor the numbers by the first 80 prime numbers first. See attached code. I know that these 80 IF-THEN statements can be replaced to make the code neater but that is not the problem.
The problem is that when the count reaches 65535, another IF statement causes the program to STOP. It does stop but for only about 51 seconds. Then it continues. It doesen't reset. It just looks like it continues because W1 goes back to 1 (rolls over?) but W4, which counts the number of primes, picks up where it paused and counts up from there as prime numbers are found again.
The program can be run as is to observe the problem, it only takes a few minutes with the chip at 16MHz, but if anyone wants to run the complete program, change the W1 = 65001 line at the top to W1 = 3.
The same issue occurs if I replace the STOP command with END.
The issue must be with the code because if I program the 28X1 to count from 65500 to 65535 then STOP, it does stop.
Has anyone ever seen this before?
Other info: The chip is bread boarded with an LED on pin 7, external resonator, battery powered and stays connected to my computer with a serial cable (non-USB) while the program runs.
Dave E
P.S. I first programmed an 08M with a very simple and heavy number crunching "find primes" program and it has been running for about 24 hours now at 8MHz and is up to 28111 which is the 3069th prime number.
Could be an interesting "see how fast it can be done with an 08M" contest.
I ran across an odd problem that maybe some of you can help with.
Just for a "see how long it takes" experiment I programmed a 28X1 to find prime numbers between 3 and 65535. It took a few hours to find them so naturally I tried to find ways to speed things up so I added about 80 IF-THEN statements to factor the numbers by the first 80 prime numbers first. See attached code. I know that these 80 IF-THEN statements can be replaced to make the code neater but that is not the problem.
The problem is that when the count reaches 65535, another IF statement causes the program to STOP. It does stop but for only about 51 seconds. Then it continues. It doesen't reset. It just looks like it continues because W1 goes back to 1 (rolls over?) but W4, which counts the number of primes, picks up where it paused and counts up from there as prime numbers are found again.
The program can be run as is to observe the problem, it only takes a few minutes with the chip at 16MHz, but if anyone wants to run the complete program, change the W1 = 65001 line at the top to W1 = 3.
The same issue occurs if I replace the STOP command with END.
The issue must be with the code because if I program the 28X1 to count from 65500 to 65535 then STOP, it does stop.
Has anyone ever seen this before?
Other info: The chip is bread boarded with an LED on pin 7, external resonator, battery powered and stays connected to my computer with a serial cable (non-USB) while the program runs.
Dave E
P.S. I first programmed an 08M with a very simple and heavy number crunching "find primes" program and it has been running for about 24 hours now at 8MHz and is up to 28111 which is the 3069th prime number.
Could be an interesting "see how fast it can be done with an 08M" contest.
Attachments
-
5.2 KB Views: 17