serial peripheral interface

         Serial peripheral interface


   
#include <LPC21xx.H>

void spi_data(int data)
{
 IOCLR0 = (1 << 7);    // CLEARING GPIO PIN
 S0SPDR = data ;
 while(!(S0SPSR & (1 << 7))); //CHECK STATUS , MONITOR FLAG   (AFTER DATA TRANSFER THE 7TH BIT SET)
 IOSET0 = (1 << 7);
}

int main()
{
 PINSEL0 |= (1 << 8)|(1<<10)|(1 << 12); //MISO,MOSI,SCK
 PINSEL0 &= ~(1 << 9)|(1<<11)|(1 << 13); //MISO,MOSI,SCK

 IODIR0 |= (1 << 7);      //SS we are taking GPIO
 S0SPCR = (1 << 2)|(1 <<  5); //enabling the SPI and 5 bit for master mode
 S0SPCCR = 8;     //8,10,12,14 we can give given by manufacture (refer notes formula)
 while(1)
 {
 
  //7 SEGMENT DISPLAY CMDS
  spi_data(0x0C01);   // 0XC00-OFF,0XC01-ON
  spi_data(0x0900);  // decode mode (0X0900)---(Normal mode 0x0900)(can control inside the segment how may led will on
  spi_data(0x0A0F);  // OXO90F -max intencity 
  spi_data(0x0B03);  // 0x0B03 -- scan limit (how many segment on ..here we mention 3 so its on 4 segment)

  spi_data(0x0167);// DATA
  spi_data(0x023e);
  spi_data(0x034e);
  spi_data(0x0401);
 }
}

Comments

Popular posts from this blog

READING VALUES FROM SENSOR AND THAT WRITING TO EEPROM

Smart Power management system in any management system

Locker Security Sytem Using Humun Detect Sensor and OTP Throuhgt Bluettoth