View previous topic :: View next topic |
Author |
Message |
ercarlitosg
Joined: 08 Sep 2014 Posts: 20
|
PIC18F87K90 and TCP IP ENC28J60 not working |
Posted: Thu Aug 27, 2015 12:28 pm |
|
|
Hello,
I have tried to make the pic18f87k90 to talk with the enc28j60 and it doesn't works.
I am using the ccs c tcp/ip stack and debugging with mplab x I find that gets stuck on StackInit in line:
Code: | LFSRSeedRand(GenerateRandomDWORD()); |
Here gets stuck.
If anyone can help me to get in the correct direction I will be very grateful.
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 27, 2015 10:34 pm |
|
|
Debug inside this function, in the Helpers.c file:
Code: | GenerateRandomDWORD() |
There are a couple places in there where it could possibly get stuck. |
|
|
ercarlitosg
Joined: 08 Sep 2014 Posts: 20
|
|
Posted: Fri Aug 28, 2015 4:18 am |
|
|
PCM programmer wrote: | Debug inside this function, in the Helpers.c file:
Code: | GenerateRandomDWORD() |
There are a couple places in there where it could possibly get stuck. |
It's enters in a while loop, that presumably generate random seeds in one second, because there are so many iterations that I couldn't find where it gets out of the loop. But when I pause the program again it points me to the #use delay instruction on my include file.
I don't know what is it.
Thanks. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Fri Aug 28, 2015 7:51 am |
|
|
The #use delay gets pointed to, when you are in anything using a delay.
The function uses the ADC to generate values to seed the random number generator. There is a note that there will be problems if you have the ADC being accessed in an interrupt. In this case you need to disable interrupts before calling this function.
It uses the difference in speed of the internal ADC clock, and the system clock. It takes about half a million instruction cycles to execute, so if running in simulator, can take a long time. It should timeout if it fails. At the end of the day for debugging, you can run without the random number generator being re-seeded.
It will loop for ever, if it sees 'no entropy' from it's operation. So in a simulator, you have to deliberately introduce some change. |
|
|
ercarlitosg
Joined: 08 Sep 2014 Posts: 20
|
|
Posted: Fri Aug 28, 2015 8:04 am |
|
|
Ttelmah wrote: | The #use delay gets pointed to, when you are in anything using a delay.
The function uses the ADC to generate values to seed the random number generator. There is a note that there will be problems if you have the ADC being accessed in an interrupt. In this case you need to disable interrupts before calling this function.
It uses the difference in speed of the internal ADC clock, and the system clock. It takes about half a million instruction cycles to execute, so if running in simulator, can take a long time. It should timeout if it fails. At the end of the day for debugging, you can run without the random number generator being re-seeded.
It will loop for ever, if it sees 'no entropy' from it's operation. So in a simulator, you have to deliberately introduce some change. |
I am not in simulator.
I am with a board with the 18f87k90 and the olimex enc28j60 module.
Also I am not using adc and that function is from the unmodified ccs c tcp ip stack.
Anyway, I found an example with the old stack and I will stick with it to learn about how microchip stack works and then move to the new stack.
Thanks |
|
|
|