Had an interesting issue with the SPI interface. I'm interfacing to a ADS1271 device and reading in data every 50kHz. If the optimisation switch in the makefile is set to -O0 then it gives very adhoc transfers so I have found that this needs to always be set to -O2, also when using this setting do NOT use -DDEBUG in the XC compiler field as this will override the -O2 setting and the same issue returns.
Conclusion is that something in the SPI library code is not happy unless it is optimised, would love to spen time finding the problem but I'm to busy to do so.
SPI master is adhoc when optimisation turned off
-
- Newbie
- Posts: 1
- Joined: Sat Jan 07, 2017 2:10 pm
-
- XCore Addict
- Posts: 230
- Joined: Wed Mar 10, 2010 12:46 pm
Hi aelmicro,
This is not too surprising. There will be lots of issues if code is not able to run fast enough to keep up with the physical interface. If you compile with -O0 the code will run with very significant performance degradation.
I would almost never recommend using -O0. It can sometimes be useful when trying to debug some code and the optimised code is hard to step through in the debugger. However, the tools support using -g with any optimisation level so that in general you should be able to debug with optimisations on. A good default optimisation level is -Os given that it results in pretty good code while saving memory (which is a scarce resource).
Regards,
Peter
This is not too surprising. There will be lots of issues if code is not able to run fast enough to keep up with the physical interface. If you compile with -O0 the code will run with very significant performance degradation.
I would almost never recommend using -O0. It can sometimes be useful when trying to debug some code and the optimised code is hard to step through in the debugger. However, the tools support using -g with any optimisation level so that in general you should be able to debug with optimisations on. A good default optimisation level is -Os given that it results in pretty good code while saving memory (which is a scarce resource).
Regards,
Peter