Hi
I have built a daughter board to with an AD5524A DAC, so just need some example code to look at how I can use the SPI 1 which the device is connected to to start communicating with it. Is there one available?
Samuel
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi
I have built a daughter board to with an AD5524A DAC, so just need some example code to look at how I can use the SPI 1 which the device is connected to to start communicating with it. Is there one available?
Samuel
Hi Samuel,
When you register your board you can download software examples calles BSL (board support library) from Logic. Also, please see the BIOS PSP and starterware software offerings from TI:
http://processors.wiki.ti.com/index.php/Getting_Started_Guide_for_OMAP-L138 - If you are going to use the ARM + DSP
http://processors.wiki.ti.com/index.php/Getting_Started_Guide_for_C6748 - If you are using the DSP only
Hi Mariana,
Thanks for the reply. I have tried evmomapl138_spi.c from the BSL from PDL. It looks like its written for 8-bit operation. I am trying to get it for 16-bit operation, I have built a daughter board that interfaces to the SPI1 on Zoom board trying to interface to the DAC AD5542A. Looks like the hardware is working, think the only the initiation needs to be adjusted. I have tried the following with no success.
spi->SPIGCR1 = CLKMOD | MASTER;
// config pin options.
spi->SPIPC0 = SOMI | SIMO | CLK | SCS0;
// config the cs active...high or low.
spi->SPIDEF = 0;
// clear csnr for active low and set cs default to 1.
spi->SPIDAT1 = 0;
SETBIT(spi->SPIDEF, CSDEF0);
// config spi direction, polarity, and phase.
spi->SPIFMT0 = 0;
SETBIT(spi->SPIFMT0, SHIFTDIR);
SETBIT(spi->SPIFMT0, POLARITY);
// set the prescaler and character length.
prescaler = (((SYSCLOCK2_HZ / 1000000) - 1) & 0xFF);
SETBIT(spi->SPIFMT0, (prescaler << SHIFT_PRESCALE));
SETBIT(spi->SPIFMT0, (DEFAULT_CHAR_LEN << SHIFT_CHARLEN));
spi->SPIDELAY = (16 << 24) | (16 << 16);
// disable interrupts.
spi->SPIINT = 0x00;
spi->SPILVL = 0x00;
// enable spi.
SETBIT(spi->SPIGCR1, ENABLE);
The following is the changes on the header file.
#define DEFAULT_CHAR_LEN (16)
Where am I making the mistake here?
Samuel
Hi Mariana, I managed to solved it, actually. I have another that is I get seems to get the GPIO working using the following code.
EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_GPIO, PSC_ENABLE);
EVMOMAPL138_pinmuxConfig(PINMUX_GPIO_BUFF_OE_REG, PINMUX_GPIO_BUFF_OE_MASK, PINMUX_GPIO_BUFF_OE_VAL);
GPIO_setDir(GPIO_BANK0, 15, GPIO_OUTPUT);
GPIO_setOutput(GPIO_BANK0, 15, 1);
GPIO_setOutput(GPIO_BANK0, 15, 0);
According to the datasheet this should work but its not working I even checked on if the registers are responding to the changes and they are, but on the level on the GPIO was still high when measured.
Samuel
Hi Samuel,
Please notice that your pin mux setting in the function below is enabling GPIO 6 of bank 2:
Samuel Raj1 said:EVMOMAPL138_pinmuxConfig(PINMUX_GPIO_BUFF_OE_REG, PINMUX_GPIO_BUFF_OE_MASK, PINMUX_GPIO_BUFF_OE_VAL);
as you can see in the source code:
#define PINMUX_GPIO_BUFF_OE_REG (6) - pin mux control register 6 - see section 11.5.10.7 of the OMAP-L138 DSP+ARM Processor Technical Reference Manual
#define PINMUX_GPIO_BUFF_OE_MASK (0x000000F0) - this is to clear the field of the register
#define PINMUX_GPIO_BUFF_OE_VAL (0x00000080) - this is to set it to enable GP2[6]
So that will not be compatible with bank 0, pin 15 that you are trying to use at:
Samuel Raj1 said:GPIO_setDir(GPIO_BANK0, 15, GPIO_OUTPUT);
GPIO_setOutput(GPIO_BANK0, 15, 1);
GPIO_setOutput(GPIO_BANK0, 15, 0);
Please check the OMAP-L138 DSP+ARM Processor Technical Reference Manual, for the correct pin mux register for your GPIO choice - section 11.5.
Hi Mariana,
One more issue I notice. When I try this on SPI0 I can seem to switch off the CLK that keeps running. Is it possible to switch off this CLK and use GP1[8] as an IO. How do I switch off the SPI 0 and use it as a GPIO.
Samuel
Hi Samuel,
As the pins are shared by different peripherals in the processor, you need to configure what is the function that you want for each pin. You do that by setting the pin mux registers. The document I sent before has details on how to configure each pin, but TI also created an utility to make it easier for you. Please the the document in the link below - it should help you achieve what you need:
Hi Mariana,
I tired the MUX on the SPI 0, it does work. The GP1[8] pin does toggle according to my code. However I see a clock of about 1kHz sitting on this. Whenever I toggle the IO the clock moves in level with it. I believe this clock is from the LAN8710. How to I turn it off?
Samuel