Quantcast
Channel: Wireless Connectivity
Viewing all articles
Browse latest Browse all 116964

Forum Post: RE: U0CSR.TX_BYTE won't clear

$
0
0

Igor,

I have made the change you suggested about moving the definition of PxSEL and PxDIR before setting P0_4 and P2_0.  This has not changed anything.  I moved all my code to the beginning of ZMain.c to remove the possiblity of any interupts causing problems.  I still see the same problems

1) If I step through the code, I see the ROM respond with it's ID on the logic analyzer, but I never see it appear in U0DBUF (should I see the actual data in the debuuger window showing U0DBUF?  I would think so but I am new to this debugger)

2) If I execute the code. I do not see all bus transactions happen.  Only the first and last writes happen so the ROM never responds with its ID.  I'm puzzled and at a loss as to why i can step through the code and it works, but if I execute it I get different results.  Code is below.

int main( void )
{
  byte inbyte = 0;
  // Turn off interrupts
  osal_int_disable( INTS_ALL );
// Mike_t DEBUG
   PERCFG &= ~0x01;     // PeRCFG.U0CFG = 0 - Set Alt 1 location for SPI interface pg 78 swru191
  P0SEL |= 0x2C;      // pins set to peripheral function, not GPIO ,pg 78
  P0SEL &= ~0x10;     // Clear bit 4, enable GPIO function
  P2DIR |= 0x01;      // Set GPIO as output for A2D
  P0DIR |= 0x10;      // Set GPIO as output for ROM
 
  // Configure the baud rate
  U0BAUD = 0x3B;          // 2400
  U0GCR &= 0x0E0;
  U0GCR |= 0x06;      //
 
  // Configure SPI master mode
  U0CSR &= ~0x0A0;     // pg 152, clear bit <7>, <5>
 
  // Configure phase, polarity and bit order
  U0GCR |= 0x0E0;     // Order MSB, Polarity Positive, Phase data on MOSI
  P0_4 = 1;
  P2_0 = 1;
  P0_4 = 0;
 
  U0DBUF = 0X90;
  while (!U0CSR&&0xFD);
  U0CSR &= 0xFD;
 
  U0DBUF =0X00;
  while (!U0CSR&&0xFD);
  U0CSR &= 0xFD;
 
  U0DBUF = 0X00;
  while (!U0CSR&&0xFD);
  U0CSR &= 0xFD;
 
  U0DBUF = 0X00;
  while (!U0CSR&&0xFD);
  U0CSR &= 0xFD;
 
  U0DBUF = 0XAA;                <-- ROM ID appears on bus durring the same cycles as ths write.  Never see it in debugger U0DBUF
  while (!U0CSR&&0xFD);
  U0CSR &= 0xFD;
 
  //U0DBUF = 0XAA;
  //while (!U0CSR&&0xFD);
  inbyte = U0DBUF;    <-------- The variable never gets set to ROM ID, even when I step through the code.
 // P0_4 = 1;
  U0CSR &= 0x0FD;
  P0_4 = 1;
 
  // Initialization for board related stuff such as LEDs
  HAL_BOARD_INIT();


Viewing all articles
Browse latest Browse all 116964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>