View previous topic :: View next topic |
Author |
Message |
rjrodrig
Joined: 09 Sep 2009 Posts: 7
|
Error Codes <errno.h> where are they? |
Posted: Mon Jan 13, 2014 3:46 pm |
|
|
I am writing some code for PIC24 target, and I am interest to know whether or not spi_xfer() failed or not. Since this is a canned function something may go wrong and I want to report that. Using errno.h header file the variable errno gets written by the error code which caused the error which will be a number other than 0.
1. How do I find out a list of error codes within CCS compiler? I want to know if the number is 2233 maybe that mean the SPITXBUF got overwritten or something like that. Does anyone know the error codes?
regards,
rjrodrig |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Jan 14, 2014 2:04 am |
|
|
Errno.h, is for maths errors. Nothing to do with spi.
For rs232, there is a single variable RS232_ERRORS, with a couple of bits reflecting the hardware error bits. Nothing more.
For SPI, the only errors are the hardware bits.
You need to understand, that the CCS functions, are not high level functions talking to an OS, but really basic low level functions talking just directly to the port hardware. As such, there is no library of error numbers, but just what the hardware gives you.
So there are no 'error codes'. Just direct testing of the hardware error bits. If you want to generate error codes, then your software will have to generate them.
You can see what is done, by looking at the assembler generated for an spi_xfer. The presence of errno.h, makes no difference to the code generated.
Best Wishes |
|
|
rjrodrig
Joined: 09 Sep 2009 Posts: 7
|
|
Posted: Tue Jan 14, 2014 10:22 am |
|
|
Well I was talking more in a generic sense. For example the canned function could look at the SPISTAT register and look at what happened there and report a a flag into a variable. That is all I am asking. I was trying to avoid doing this redundantly if the function already did it. For all peripherals there are hardware stats one can query. Since it is no where in the manuals I had to resort to posting. I will just do it myself I was just hoping someone at CCS had done the leg work, and I was just trying to piggy back on it. |
|
|
|