Forum: Mikrocontroller und Digitale Elektronik Fehler in Maxim AppNote


von J. K. (rooot)


Angehängte Dateien:

Lesenswert?

Hallo Leute,

Wie man an dem Thread sehen kann,
Beitrag "MAX7456 SPI - Ansteuerungsprobleme (AVR)"

beschäftige mich grade mit dem MAX7456
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/5516


und hätte den Code des AppNote's verwendet.
http://www.maxim-ic.com/appnotes.cfm/appnote_number/4184

1. Stimmt die Zuordnung nicht.
>CS is the same as is used in the MAX7456 data sheet.
>SDIN is referred to as MOSI (master out slave in).
>SDOUT is referred to as MOSI (master in slave out).
>SCLK is referred to as CK.

beides auf MOSI kurzschließen? :-) hab ich denen schon geschrieben.

2. Problem, nicht so offensichtlich:
siehe: Figure 2. Read operation (anhang) und Code von spiReadReg
1
unsigned char spiReadReg (const unsigned char regAddr)
2
{
3
4
  unsigned char SPICount;                                       // Counter used to clock out the data
5
  
6
  unsigned char SPIData;                  
7
  
8
  SPI_CS = 1;                                                   // Make sure we start with active-low CS high
9
  SPI_CK = 0;                                                   // and CK low
10
  SPIData = regAddr;                                            // Preload the data to be sent with Address and Data
11
12
  SPI_CS = 0;                                                   // Set active-low CS low to start the SPI cycle
13
  for (SPICount = 0; SPICount < 8; SPICount++)                  // Prepare to clock out the Address and Data
14
  {
15
    if (SPIData & 0x80)
16
      SPI_MOSI = 1;
17
    else
18
      SPI_MOSI = 0;
19
    SPI_CK = 1;
20
    SPI_CK = 0;
21
    SPIData <<= 1;
22
  }                                                             // and loop back to send the next bit
23
  SPI_MOSI = 0;                                                 // Reset the MOSI data line
24
  
25
  SPIData = 0;
26
  for (SPICount = 0; SPICount < 8; SPICount++)                  // Prepare to clock in the data to be read
27
  {
28
    SPIData <<=1;                                               // Rotate the data
29
    SPI_CK = 1;                                                 // Raise the clock to clock the data out of the MAX7456
30
    SPIData += SPI_MISO;                                        // Read the data bit
31
    SPI_CK = 0;                                                 // Drop the clock ready for the next bit
32
  }                                                             // and loop back
33
  SPI_CS = 1;                                                   // Raise CS
34
                      
35
  return ((unsigned char)SPIData);                              // Finally return the read data
36
}

Laut Bild werden 8 Bits ausgebeben. Das erste Bit muss aber noch beim 8. 
Takt eingelesen werden. Das letzte wird verworfen.

Der Code macht aber was anders. Er ingnoriert das 1. Bit und wertet das 
letzte (unwichtige) aus.

Sehe ich das richtig?

MFG
J.K

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.