Hallo Leute, ich versuche die SPI Schnittstelle auf dem lpc1114/302(NXP LPCEperesso Board) zum Laufen zu bringen. Leider hab ich ein Fehler den ich nicht finde. Die Code Beispiele und das UM helfen mir irgendwie nicht weiter. Ich müsste doch mit diesen Einstellungen ein CLK auf PIO0_6 messen können. Leider ist er auf GND. Was mache ich falsch oder was übersehe ich?
1 | void SPI_IOConfig(){ |
2 | |
3 | LPC_SYSCON->PRESETCTRL |= (1<<0); //Table 9 |
4 | LPC_SYSCON->SYSAHBCLKCTRL |= (1<<11); //Table 21 Enable SPI0 |
5 | LPC_SYSCON->SSP0CLKDIV = (1<<1); //Tab 22 |
6 | //Pin Cfg
|
7 | LPC_IOCON->PIO0_8 &= ~0x07; //SSP Reset Value I/O config |
8 | LPC_IOCON->PIO0_8 |= 0x01; //SSP MISO |
9 | LPC_IOCON->PIO0_9 &= ~0x07; //SSP Reset Value I/O config |
10 | LPC_IOCON->PIO0_9 |= 0x01; //SSP MOSI |
11 | |
12 | LPC_IOCON->SCK_LOC = 0x02; //Tab 147 CLK an PIO0_6 umleiten |
13 | LPC_IOCON->PIO0_6 = 0x02; //SCK0 |
14 | |
15 | // SSP SSEL is a GPIO pin
|
16 | LPC_IOCON->PIO0_2 &= ~0x07; //Reset |
17 | LPC_GPIO0->DIR |=(1<<2); |
18 | LPC_GPIO0->MASKED_ACCESS[(1<<2)] = (1<<2); //SSEL0 |
19 | }
|
20 | void SPI_Init(){ |
21 | uint8_t i, Dummy=Dummy; |
22 | |
23 | LPC_SSP0->CR0 = 0x0000; //Reset |
24 | LPC_SSP0->CR0 = 0x0107; //Tab 208 Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 0 |
25 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
|
26 | LPC_SSP0->CPSR = 0x2; //Tab 212 |
27 | |
28 | for ( i = 0; i < 8; i++ ){ |
29 | Dummy = LPC_SSP0->DR; //Tab 210 clear the RxFIFO |
30 | }
|
31 | // Enable the SSP Interrupt
|
32 | //NVIC_EnableIRQ(SSP0_IRQn); //Tab 442
|
33 | //Master Mode
|
34 | //LPC_SSP1->CR1 = (1<<1); //Tab 209 SSE
|
35 | /* Set SSPINMS registers to enable interrupts */
|
36 | /* enable all error related interrupts */
|
37 | //LPC_SSP1->IMSC = (1<<0)|(1<<1); //Tab 213
|
38 | }
|