Hi
I am trying to set up spi for an LCD that I am using, the communication is thus only one way.When I subscribe to the SPI and write to it, the result is correct but when I try to measure the clock or anything with an ossiloscope, there is only noise. Is there something i missed? I attached the code to make it more clear. I am using pin 19 as the chip select.
Any help would be much appreciated.
#include "adl_global.h"
const u16 wm_apmCustomStackSize = 1024 * 3;
#define OUTPUT_PIN 19
adl_busAccess_t busAccessMode = { 0x00, 0x00 };
s32 busSubscribeHandle;
s32 MyGpioHandle2;
adl_ioDefs_t PIN_DESCRIP2 = ADL_IO_GPIO | OUTPUT_PIN | ADL_IO_DIR_OUT;
void SPI_Write(u8 *Data, int DataLenghts) {
s32 adl_busWriteAnswer;
TRACE((2,"Write"));
TRACE((2,(ascii *)Data));
adl_ioWriteSingle(MyGpioHandle2, &PIN_DESCRIP2, TRUE);
adl_busWriteAnswer = adl_busWrite(busSubscribeHandle, &busAccessMode, 10,
Data);
TRACE((2,"Result %d",adl_busWriteAnswer));
//adl_ioWriteSingle(MyGpioHandle2, &PIN_DESCRIP2, FALSE);
}
void MyTimerHandler(u8 Id, void * Context) {
u8 *buffer;
buffer = (u8 *) adl_memGet(10);
wm_memset(buffer, 0xFF, 8);
buffer[8] = 0x00;
buffer[9] = 0x00;
SPI_Write(buffer, 10);
adl_memRelease(buffer);
}
void adl_main(adl_InitType_e InitType) {
TRACE (( 1, "Embedded Application : Main" ));
u32 spiHandle = 1;
u32 Datasize = 8;
u32 Bussize = 8;
u32 Opsize = 8;
s32 adl_busIOCtlAnswer;
adl_busSPISettings_t MySpiconfig = { 12, ADL_BUS_SPI_CLK_MODE_0,
ADL_BUS_SPI_ADDR_CS_NONE, ADL_BUS_SPI_CS_POL_HIGH,
ADL_BUS_SPI_MSB_FIRST, 0, ADL_BUS_SPI_LOAD_UNUSED,
ADL_BUS_SPI_DATA_UNIDIR, ADL_BUS_SPI_MASTER_MODE,
ADL_BUS_SPI_BUSY_UNUSED };
busSubscribeHandle = adl_busSubscribe(ADL_BUS_ID_SPI, spiHandle,
&MySpiconfig);
MyGpioHandle2 = adl_ioSubscribe(1, &PIN_DESCRIP2, 0, 0, 0);
TRACE((2,"result: %d", busSubscribeHandle));
switch (busSubscribeHandle) {
case OK:
TRACE((2, "OK"));
break;
case ADL_RET_ERR_PARAM:
TRACE((2, "ADL_RET_ERR_PARAM"));
break;
case ADL_RET_ERR_ALREADY_SUBSCRIBED:
TRACE((2, "ADL_RET_ERR_ALREADY_SUBSCRIBED"));
break;
case ADL_RET_ERR_BAD_HDL:
TRACE((2, "DL_RET_ERR_BAD_HDL"));
break;
case ADL_RET_ERR_NOT_SUPPORTED:
TRACE((2, "ADL_RET_ERR_NOT_SUPPORTED"));
break;
case ADL_RET_ERR_SERVICE_LOCKED:
TRACE((2, "ADL_RET_ERR_SERVICE_LOCKED"));
break;
}
adl_busIOCtlAnswer = adl_busIOCtl(busSubscribeHandle,
ADL_BUS_CMD_SET_ADD_SIZE, &Bussize);
TRACE((2,"result: %d", adl_busIOCtlAnswer));
adl_busIOCtlAnswer = adl_busIOCtl(busSubscribeHandle,
ADL_BUS_CMD_SET_DATA_SIZE, &Datasize);
TRACE((2,"result: %d", adl_busIOCtlAnswer));
adl_busIOCtlAnswer = adl_busIOCtl(busSubscribeHandle,
ADL_BUS_CMD_SET_OP_SIZE, &Opsize);
TRACE((2,"result: %d", adl_busIOCtlAnswer));
TRACE((2,"SPI init complete"));
adl_tmrSubscribe(TRUE, 20, ADL_TMR_TYPE_100MS, MyTimerHandler);
// TO DO : Add your initialization code here
}