Hi,
I have tried your code, I suppose that the SPI clock is incorrect:
original line:
SYSCON->SPI0CLKSEL|=1<<11; //SPI CLK
change to
SYSCON->SPI0CLKSEL=1<<11; //SPI CLK
xiangjun_rong_0-1688704374312.png
The SEL default value is 7, which means none of SPI clock. After you or with 1, it is still 7, you should have been set it as 0x01.
I used the following code, I can see clock signal SCK and MOSI from PIO0_15/PIO0_16 of LPCXPresso804 board.
Hope it can help you
BR
XiangJun Rong
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "LPC804.h"
#include "fsl_debug_console.h"
void SPI0_config(void);
/* TODO: insert other include files here. */
/* TODO: insert other definitions and declarations here. */
/*
* @brief Application entry point.
*/
int main(void) {
/* Init board hardware. */
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif
PRINTF("Hello World\n");
/* Force the counter to be placed into memory. */
volatile static int i = 0 ;
/* Enter an infinite loop, just incrementing a counter. */
SPI0_config();
while (1)
{
while ((SPI0->STAT & SPI_STAT_TXRDY_MASK) == 0U)
{
}
// SPI0->TXDATCTL |=0X075000FF;
SPI0->TXDAT = 0XAA;
asm("nop");
}
while(1) {
i++ ;
/* 'Dummy' NOP to allow source level single stepping of
tight while() loop */
__asm volatile ("nop");
}
return 0 ;
}
void SPI0_config(void)
{
//
//SYSCON->SYSAHBCLKCTRL0 |= 1<<11; //Enable clock
//SYSCON->PRESETCTRL0 &=~(1<<11); //SPI clear
//SYSCON->PRESETCTRL0 |=(1<<11);
SYSCON->SYSAHBCLKCTRL0 |= 1<<7; //SWM CLK
//SYSCON->PRESETCTRL0 &=~(1<<7);
//SYSCON->PRESETCTRL0 |=(1<<7);
SWM0->PINASSIGN_DATA[2]=0X00000000;
SWM0->PINASSIGN_DATA[2]|=(0x10)<<0; //CLK PIO0_16PORT0-22
SWM0->PINASSIGN_DATA[2]|=(0X0F)<<8; //MOSI PORT0-15
SWM0->PINASSIGN_DATA[2]|=(0X08)<<24; //Chip select- SSEL0 PORT0-8
SYSCON->SYSAHBCLKCTRL0 |= 1<<11; //Enable clock
SYSCON->SPI0CLKSEL=1<<11; //SPI CLK
SPI0->CFG = 0x125; //Master enable//CLK POLARITY 0X25;
SPI0->DLY =0x2000; //Enabled FRAME DELAY
SPI0->TXDATCTL =0X7430000;//843
SPI0->DIV = 0XA8;
}