local time: :: ()
heure officielle (en France) : ::(TZ:)
Heure UTC client: :: Offset client: s - delai: ms - - timeZone: Heure UTC: ::This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:programs_to_communicate_with_the_dds [2016/03/14 14:21] fwiotte |
en:programs_to_communicate_with_the_dds [2016/03/14 14:29] (current) fwiotte |
||
---|---|---|---|
Line 1: | Line 1: | ||
===Interface with TI microcontroller: the MSP430=== | ===Interface with TI microcontroller: the MSP430=== | ||
- | Sample program in C written in the microcontroller MSP430F169 | + | Sample program in C written in the microcontroller MSP430F169 this microcontroller has 2 SPI ports. |
- | + | ||
- | This microcontroller has 2 SPI ports. | + | |
SPI mode: Single-bit serial 2-wire Mode (default mode) | SPI mode: Single-bit serial 2-wire Mode (default mode) | ||
Line 90: | Line 88: | ||
while (i <num_byte); | while (i <num_byte); | ||
} | } | ||
- | Interface with a TI ARM microcontroller: the TM4C123GH6PM | + | ===Interface with a TI ARM microcontroller: the TM4C123GH6PM === |
Example C program written in ARM microcontroller TM4C123GH6PM | Example C program written in ARM microcontroller TM4C123GH6PM | ||
Line 96: | Line 94: | ||
This microcontroller has 4 SPI ports. Default = 80MHz clock | This microcontroller has 4 SPI ports. Default = 80MHz clock | ||
- | SPI mode: Single-bit serial 3-wire fashion | + | SPI mode: Single-bit serial 3-wire, the routine for the SPI mode data TM4C123GH6PM ARM: |
- | the routine for the SPI mode data TM4C123GH6PM ARM: | ||
- | int i = 0; | + | int i = 0; |
- | SSI0_DR_R = statement; | + | SSI0_DR_R = statement; |
- | while (num_byte) | + | while (num_byte) |
- | { | + | { |
while (! (SSI0_SR_R & SSI_SR_TNF)) {} // SPI0 of TM4C123GH6PM | while (! (SSI0_SR_R & SSI_SR_TNF)) {} // SPI0 of TM4C123GH6PM | ||
SSI0_DR_R = data >> (num_byte-1-i) * 8; | SSI0_DR_R = data >> (num_byte-1-i) * 8; | ||
num_byte--; | num_byte--; | ||
- | } | + | } |
- | while (! (SSI0_SR_R & SSI_SR_TNF)) | + | while (! (SSI0_SR_R & SSI_SR_TNF)) |
{ | { | ||
; | ; | ||
} | } | ||
+ | | ||
+ | | ||
+ | |||
+ | The init routine (SPI) for the ARM TM4C123GH6PM: | ||
+ | |||
+ | // Enable Peripheral SSI0 | ||
+ | SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA); // Enable GPIO port A SSI0. | ||
+ | SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI0); | ||
+ | GPIOPinConfigure (GPIO_PA2_SSI0CLK); | ||
+ | GPIOPinConfigure (GPIO_PA3_SSI0FSS); | ||
+ | GPIOPinConfigure (GPIO_PA5_SSI0TX); | ||
+ | GPIOPinTypeSSI (GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_3 | GPIO_PIN_2); | ||
+ | // GPIOPinTypeSSI (GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_2); | ||
+ | SSIConfigSetExpClk (SSI0_BASE, SysCtlClockGet () SSI_FRF_MOTO_MODE_0, | ||
+ | SSI_MODE_MASTER, 10000000, 8); | ||
+ | SSIEnable (SSI0_BASE); // Enable the SSI | ||
+ | |||
+ | Example of initializing Port B on ARM TM4C123GH6PM: | ||
+ | |||
+ | // Void PortB_Init (void) | ||
+ | volatile unsigned long delay; | ||
+ | SYSCTL_RCGC2_R | = 0x00000002; // 1) activate clock for Port B | ||
+ | delay = SYSCTL_RCGC2_R; // Allow for time clock to start | ||
+ | GPIO_PORTB_AMSEL_R = 0x00; // 3) disable analog one PB | ||
+ | GPIO_PORTB_PCTL_R = 0x00000000; // 4) PCTL GPIO is PB0 | ||
+ | GPIO_PORTB_DIR_R | = 0xFF; // 5) PB0-PB7 is out | ||
+ | // GPIO_PORTB_AFSEL_R & = ~ 0x01; // 6) disable alt funct on PB0 | ||
+ | GPIO_PORTB_AFSEL_R & = ~ 0xFF; // 6) disable alt funct on PB0-PB7 | ||
+ | GPIO_PORTB_DEN_R | = 0xFF; // 7) enable digital I / O on PB0-PB7 | ||
+ | |||
+ | |||
+ | Example of initializing a USB-PORT for UART0 serial communication on the ARM TM4C123GH6PM: | ||
+ | |||
+ | // Void init_UART0 (void) | ||
+ | SysCtlPeripheralEnable (SYSCTL_PERIPH_UART0); | ||
+ | SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA); | ||
+ | GPIOPinConfigure (GPIO_PA0_U0RX); | ||
+ | GPIOPinConfigure (GPIO_PA1_U0TX); | ||
+ | GPIOPinTypeUART (GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); | ||
+ | UARTConfigSetExpClk (UART0_BASE, SysCtlClockGet (), 9600, | ||
+ | (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); | ||
+ | |||
+ | | ||
+ | Example of declaration and initialization of the frequency word registers: | ||
+ | |||
+ | // // AD9852 | ||
+ | FTW0_ADRESS int = 0x02; | ||
+ | // Unsigned long long FTW0 = 0x17E4B17E4B1; //1.75MHz@300MHz clk | ||
+ | unsigned long long FTW0; | ||
+ | // Float FTW0 = 0x17E4B17E4B1; //1.75MHz@300MHz clk | ||
+ | FTW0_NUM_BYTE int = 0x06; | ||
+ | // // AD9858 | ||
+ | FTW1_ADRESS int = 0x03; | ||
+ | unsigned long FTW1 = 0x418937; // @ 1000MHz 1MHz clk | ||
+ | FTW1_NUM_BYTE int = 0x04; | ||
+ | // // AD9858 | ||
+ | CFR_ADRESS int = 0x00; | ||
+ | unsigned long CFR = 0x79; // MSB first | ||
+ | CFR_NUM_BYTE int = 0x04; |