+ Reply to Thread
Results 1 to 8 of 8

Thread: How do i do a bit read

  1. #1
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125

    How do i do a bit read

    Hey people i have a problem im from ardiuno ide and moved to dave which is 100% better but my prpblem seem to be bit read set and modify a individual bit how do i do that with dave?
    Reading Bits and setting individual Bits is what i wanna do thats my question i see in ardiuno they have bitread() can i use that? bitRead(x, n) would the x beconsider the register i wanna access and n would be the specific bit right i wanna read ??? How can i apply this to dave. Also i notice dave has spi recieve is that the same as reading a byte?
    Last edited by pandadesign; Jul 25th, 2019 at 12:45 PM.

  2. #2
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125
    void setup ()
    {
    int pin_ign5;
    uint8_t data = 0;
    int datarecieve;
    status = DAVE_Init(); // SPI_MASTER_Init() is called from DAVE_Init()
    if(status == DAVE_STATUS_SUCCESS)
    {
    data = ((IN_STAT_COMP)>>24);//Input Enable Register Go /* Send 4th byte of 32bit start address */ need to read
    SPI_MASTER_EnableSlaveSelectSignal(&SPI_MASTER_0, SPI_MASTER_SS_SIGNAL_0);
    SPI_MASTER_Transmit(&SPI_MASTER_0, &data, 1);
    while(SPI_MASTER_0.runtime->tx_busy);
    datarecieve=bitRead(IN_STAT_COMP,4);
    if (datarecieve == 0x01 )
    {
    pin_ign5=true;
    SPI_MASTER_DisableSlaveSelectSignal(&SPI_MASTER_0) ;
    }
    }


    IN_STAT_COMP is the resister i wanna access like the code above bits (32-24)
    datarecieve is the bit read im trying to use just like ardiuno can this work like above code?
    also when i wanna read IN_STAT_COMP do i spi transmit like above code then use the bitread()?
    aslo is spi recieve the same has reading a byte but can i also read a bit within a byte does dave have this somewhere?

    these are from the ardiuno header can i use this in dave also?
    #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
    #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))


    or can i use this
    #define BitVal(data,y) ( (data>>y) & 1) /** Return Data.Y value **/
    #define SetBit(data,y) data |= (1 << y) /** Set Data.Y to 1 **/
    #define ClearBit(data,y) data &= ~(1 << y) /** Clear Data.Y to 0 **/
    #define TogleBit(data,y) (data ^=BitVal(y)) /** Togle Data.Y value **/
    #define Togle(data) (data =~data ) /** Togle Data value **/

    and a example
    uint8_t number = 0x05; //0b00000101
    uint8_t bit_2 = BitVal(number,2); // bit_2 = 1
    uint8_t bit_1 = BitVal(number,1); // bit_1 = 0

    SetBit(number,1); // number = 0x07 => 0b00000111
    ClearBit(number,2); // number =0x03 => 0b0000011
    Last edited by pandadesign; Jul 25th, 2019 at 12:44 PM.

  3. #3
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125
    could this work?????

    void readign5()
    {
    uint32_t tmp;
    uint8_t data = 0;
    #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
    int datarecieve=0;
    uint32_t status1 = 0;
    uint32_t status2 = 0;
    SPI_MASTER_EnableSlaveSelectSignal(&SPI_MASTER_0, SPI_MASTER_SS_SIGNAL_0);
    /* Clear the flags */
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_RECEIVE_INDICATION);
    if(status == DAVE_STATUS_SUCCESS)
    {
    /*Load the command*/
    data = IN_STAT_COMP;//bits 31-24
    /* Send the read status register command to SPI flash chip */
    SPI_MASTER_Transmit(&SPI_MASTER_0, &data, 1);
    while(SPI_MASTER_0.runtime->tx_busy);
    /* Wait till dummy data is received from chip */
    do
    {//GET STATUS
    status1 = SPI_MASTER_GetFlagStatus(&SPI_MASTER_0,XMC_SPI_CH_ STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
    status2 = SPI_MASTER_GetFlagStatus(&SPI_MASTER_0,XMC_SPI_CH_ STATUS_FLAG_RECEIVE_INDICATION);
    }
    while(((status1 == 0) && (status2 == 0)));
    /* Clear the flags */
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_RECEIVE_INDICATION);
    /* Receive the status command from the SPI flash chip */
    SPI_MASTER_Receive(&SPI_MASTER_0,&tmp, 1);
    while(SPI_MASTER_0.runtime->rx_busy);
    datarecieve=bitRead(tmp,4);//READ BIT 4 WHICH IS IGN5 // I ONLY WANT TO READ BIT 4 BACK TO SEE IF ITS A TRUE==1 OR FALSE==0
    SPI_MASTER_DisableSlaveSelectSignal(&SPI_MASTER_0) ;
    if (datarecieve == 0x01 )
    {
    pin_ign5=true;
    }
    else if (datarecieve == 0x00 )
    {
    pin_ign5=false;
    }
    }
    return pin_ign5;
    }
    Last edited by pandadesign; Jul 25th, 2019 at 03:43 PM. Reason: to make better sense what i need help on

  4. #4
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125
    Can someone answer my questions

  5. #5
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125
    Really over a 100 view and not a single respond

  6. #6
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125
    Really over a 200 view and not a single respond

  7. #7
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125
    Really over a 300 view and not a single respond????? does infineon stand behind there product or not

  8. #8
    Beginner Beginner pandadesign is on a distinguished road
    Join Date
    Nov 2017
    Posts
    14
    Points
    125
    IS THIS THE RIGHT WAY??????????


    int readign5()
    {
    DAVE_STATUS_t status;
    status = DAVE_Init(); // SPI_MASTER_Init() is called from DAVE_Init()
    uint8_t tmp[3];
    uint8_t data = 0;
    int pin_ign5;
    int datarecieve=0;
    uint32_t status1 = 0;
    uint32_t status2 = 0;
    SPI_MASTER_EnableSlaveSelectSignal(&SPI_MASTER_0, SPI_MASTER_SS_SIGNAL_0);
    /* Clear the flags */
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_RECEIVE_INDICATION);
    if(status == DAVE_STATUS_SUCCESS)
    {
    /*Load the command*/
    data = (0 & IN_STAT_COMP);//bits 31-24 //READ COMMAND
    /* Send the read status register command to SPI flash chip */
    SPI_MASTER_Transmit(&SPI_MASTER_0, &data, 1);
    while(SPI_MASTER_0.runtime->tx_busy);
    /* Wait till dummy data is received from chip */
    do
    {//GET STATUS
    status1 = SPI_MASTER_GetFlagStatus(&SPI_MASTER_0,XMC_SPI_CH_ STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
    status2 = SPI_MASTER_GetFlagStatus(&SPI_MASTER_0,XMC_SPI_CH_ STATUS_FLAG_RECEIVE_INDICATION);
    }
    while(((status1 == 0) && (status2 == 0)));
    /* Clear the flags */
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_ALTERNATIVE_RECEIVE_INDICATION);
    SPI_MASTER_ClearFlag(&SPI_MASTER_0,XMC_SPI_CH_STAT US_FLAG_RECEIVE_INDICATION);
    /* Receive the status command from the SPI flash chip */
    SPI_MASTER_Receive(&SPI_MASTER_0,tmp,3);
    while(SPI_MASTER_0.runtime->rx_busy);
    datarecieve=bitRead(tmp[3],4);//READ BIT 4 WHICH IS IGN5 // I ONLY WANT TO READ BIT 4 BACK TO SEE IF ITS A TRUE==1 OR FALSE==0
    SPI_MASTER_DisableSlaveSelectSignal(&SPI_MASTER_0) ;
    }
    if (datarecieve == 0x01 )
    {
    pin_ign5=1;
    }
    else if (datarecieve == 0x00 )
    {
    pin_ign5=0;
    }
    return pin_ign5;
    }

+ Reply to Thread
Disclaimer

All content and materials on this site are provided as is. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.