Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    Matheus reacted to energia in SPI pin map for Stellaris Launchpad (LM4F120)   
    Well, I was wrong. The default pin would be PA_5 which is PIN 8. This is what is in the code and the pin diagram has an error in it.
    So, I would make CS pin 8 and try again. If that still does not work then replace the last 2 functions in the original Sketch (http://sparkfun.com/tutorial/ADXL/ADXL345_Basic.pde) with the code below. I will have to change the SPI library in the next release to be strictly like the Wiring/Arduino implementation.
    //This function will write a value to a register on the ADXL345. //Parameters: // char registerAddress - The register to write a value to // char value - The value to be written to the specified register. void writeRegister(char registerAddress, char value){ //Set Chip Select pin low to signal the beginning of an SPI packet. digitalWrite(CS, LOW); //Transfer the register address over SPI. SPI.transfer(registerAddress, SPI_CONTINUE); //Transfer the desired register value over SPI. SPI.transfer(value, SPI_CONTINUE); //Set the Chip Select pin high to signal the end of an SPI packet. digitalWrite(CS, HIGH); } //This function will read a certain number of registers starting from a specified address and store their values in a buffer. //Parameters: // char registerAddress - The register addresse to start the read sequence from. // int numBytes - The number of registers that should be read. // char * values - A pointer to a buffer where the results of the operation should be stored. void readRegister(char registerAddress, int numBytes, char * values){ //Since we're performing a read operation, the most significant bit of the register address should be set. char address = 0x80 | registerAddress; //If we're doing a multi-byte read, bit 6 needs to be set as well. if(numBytes > 1)address = address | 0x40; //Set the Chip select pin low to start an SPI packet. digitalWrite(CS, LOW); //Transfer the starting register address that needs to be read. SPI.transfer(address, SPI_CONTINUE); //Continue to read registers until we've read the number specified, storing the results to the input buffer. for(int i=0; i<numBytes; i++){ values[i] = SPI.transfer(0x00, SPI_CONTINUE); } //Set the Chips Select pin high to end the SPI packet. digitalWrite(CS, HIGH); }
  2. Like
    Matheus reacted to energia in SPI pin map for Stellaris Launchpad (LM4F120)   
    Not a stupid question at all. The pin mapping for the Stellaris Launchpad can be found here: https://github.com/energia/Energia/wiki/Hardware
    The default SPI pins are PB_6 (MISO), PB_7 (MOSI) and, PB_4 (SCK). Note that in the example code there the Chip Select pin is mapped to pin 10 (int CS=10;). If you leave this as default then on the Stellaris Launchpad this would be PA_7 (See pin mapping).
  • Create New...