Pq to tentando fazer a comunicação e tá enchendo o saco, cheio de probleminha, as vezes lê as vezes não, as vezes dá resultado maluco, aí nao sei se é coisa com o mcu ou o periferico.
to usando um código que peguei de exemplo:
- Código: Selecionar todos
LPC_SYSCON->PRESETCTRL |= 0x01; // retira reset do ssp1
LPC_SYSCON->SSPCLKDIV = 10; // clock = pclk/10
LPC_SSP->CR0 = 0x0787; // 8-bit/spi/cpol=0/cpha=1/scr=15
LPC_SSP->CPSR = 0x28;
LPC_SSP->CR1 = 0x02; // spi enable
void lpc1xxx_ssp_envia(volatile unsigned char *p, unsigned int bytes)
{
unsigned int i;
for(i = 0; i < bytes; i++)
{
// só carrega se nao estiver ocupado e a FIFO do TX nao estiver cheia
while((LPC_SSP->SR & (0x02|0x10)) != 0x02) ;
LPC_SSP->DR = *p;
p++;
}
}
void lpc1xxx_ssp_recebe(volatile unsigned char *p, unsigned int bytes)
{
unsigned int i;
for( i = 0; i < bytes; i++)
{
// aguarda enquanto a FIFO do RX está vazia
while(!(LPC_SSP->SR & 0x04)) ;
*p = LPC_SSP->DR;
p++;
}
}