lpcware

ssp

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by castiel on Mon Dec 03 13:05:02 MST 2012
Please help. I try to transfer back-to-back 3 bytes(1st byte-command,2-3 bytes-address).Data is transmitted but incorrectly.Where is my mistake?Here is my code.

#include <LPC177x_8x.h>
#include "lpc177x_8x_clkpwr.h"
#include "lpc177x_8x_ssp.h"
#define SSP_DR_BITMASK(n)   ((n)&0xFFFF)
void SSP_SendData(LPC_SSP_TypeDef* SSPx, uint16_t Data)
{
SSPx->DR = SSP_DR_BITMASK(Data);
}
int main(void) {
LPC_SC->PCONP   |= (1<<15);            /* enable power  to GPIO & IOCON  */
LPC_SC->PCONP |=(1<<21);//enable  ssp0
/* APB 48МГц*/
LPC_SSP0->CPSR |= (0x2); 

LPC_IOCON->P0_15 |= (1<<1) ; //sck    
LPC_IOCON->P0_16 |= (1<<1);//ssel
LPC_IOCON->P0_17 |= (1<<1);//miso
LPC_IOCON->P0_18 |=(1<<1);//mosi

LPC_SSP0->CR0 |= (0x787);  // CPOL=0,CPHA=1,Frame Format=SPI,Serial Clock Rate=7,SSP_DATABIT_8     
  LPC_SSP0->CR1 |= (1<<1);//sse enable,,master mode
//master clock rate 3МHz
SSPTransfer(0x2);
SSPTransfer(0x0);
SSPTransfer(0x2);
}

Outcomes