0

I've recently come across spi2statbits in the following function:

int WriteSPI2( int data)

{
    int f;
    SPI2BUF = data;                 // write to buffer for TX
    while( !SPI2STATbits.SPIRBF)  
    {f=1;}// wait transfer completion
    return SPI2BUF;                 // read the received value
} // WriteSPI2

I'm using the above in conjunction with a PIC24FJ128GA010 project.

I've been searching around to find more about SPI2STATbits but haven't found actual documentation. I assume this is a fairly basic requirement.

Can someone direct me to the correct documentation?

SeanJ
  • 1,203
  • 2
  • 19
  • 39

1 Answers1

3

See page 130 of the datasheet , look for SPIxSTAT.

For the particular device, do a search for SPI2STATbits in all included header files.

It's in p24FJ128GA010.h as

#define SPI2STAT SPI2STAT extern volatile uint16_t SPI2STAT __attribute__((__sfr__)); __extension__ typedef struct tagSPI2STATBITS {...
mvorisek
  • 3,290
  • 2
  • 18
  • 53
  • If this post answers, please mark this post as an answer. – mvorisek Jan 06 '18 at 11:48
  • what is the difference between SPIxSTAT and SPIxSTATbits? I can't watch SPIxSTATbits but I can watch SPIxSTAT. SPIxSTATbits is not listed in the documentations.... – SeanJ Jan 06 '18 at 12:19
  • `SPIxSTATbits` are only used in code to refer to the bits of `SPIxSTAT` – mvorisek Jan 06 '18 at 12:23
  • Where can I find information about keywords such as bits? – SeanJ Jan 06 '18 at 12:32
  • Do a search for `SPI2STATbits` in all included header files. – mvorisek Jan 06 '18 at 12:40
  • `SPI2STATbits` is a structure that breaks up `SPI2STAT` into its individual bits. If you are using MPLAB X, right right-click and select "Nagivate|Go to declaration". You should have xc.h as an include file (in turn, it selects the specific register definition file for your processor). – EBlake Jan 08 '18 at 04:13
  • wow! Thanks! It's in `p24FJ128GA010.h` as `#define SPI2STAT SPI2STAT extern volatile uint16_t SPI2STAT __attribute__((__sfr__)); __extension__ typedef struct tagSPI2STATBITS {` CAn you add above to answer and I will accept? – SeanJ Jan 11 '18 at 14:22