|
源程序如下:- //###########################################################################
- //
- // FILE: Example_2833xI2c_eeprom.c
- //
- // TITLE: DSP2833x I2C EEPROM Example
- //
- // ASSUMPTIONS:
- //
- // This program requires the DSP2833x header files.
- //
- // This program requires an external I2C EEPROM connected to
- // the I2C bus at address 0x50.
- //
- // As supplied, this project is configured for "boot to SARAM"
- // operation. The 2833x Boot Mode table is shown below.
- // For information on configuring the boot mode of an eZdsp,
- // please refer to the documentation included with the eZdsp,
- //
- // $Boot_Table:
- //
- // GPIO87 GPIO86 GPIO85 GPIO84
- // XA15 XA14 XA13 XA12
- // PU PU PU PU
- // ==========================================
- // 1 1 1 1 Jump to Flash
- // 1 1 1 0 SCI-A boot
- // 1 1 0 1 SPI-A boot
- // 1 1 0 0 I2C-A boot
- // 1 0 1 1 eCAN-A boot
- // 1 0 1 0 McBSP-A boot
- // 1 0 0 1 Jump to XINTF x16
- // 1 0 0 0 Jump to XINTF x32
- // 0 1 1 1 Jump to OTP
- // 0 1 1 0 Parallel GPIO I/O boot
- // 0 1 0 1 Parallel XINTF boot
- // 0 1 0 0 Jump to SARAM <- "boot to SARAM"
- // 0 0 1 1 Branch to check boot mode
- // 0 0 1 0 Boot to flash, bypass ADC cal
- // 0 0 0 1 Boot to SARAM, bypass ADC cal
- // 0 0 0 0 Boot to SCI-A, bypass ADC cal
- // Boot_Table_End$
- //
- // DESCRIPTION:
- //
- // This program will write 1-14 words to EEPROM and read them back.
- // The data written and the EEPROM address written to are contained
- // in the message structure, I2cMsgOut1. The data read back will be
- // contained in the message structure I2cMsgIn1.
- //
- // This program will work with the on-board I2C EEPROM supplied on
- // the F2833x eZdsp.
- //
- //
- //###########################################################################
- // Original Author: D.F.
- //
- // $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
- // $Release Date: June 8, 2012 $
- //###########################################################################
-
-
- #include "DSP281x_Device.h"
- #include "DSP281x_Examples.h"
-
- // Note: I2C Macros used in this example can be found in the
- // DSP2833x_I2C_defines.h file
-
- // Prototype statements for functions found within this file.
-
- extern void Lcd_12864_Test(void);
- extern void Init_Port(void);
- void main(void)
- {
-
-
- // Step 1. Initialize System Control:
- // PLL, WatchDog, enable Peripheral Clocks
- // This example function is found in the DSP2833x_SysCtrl.c file.
- InitSysCtrl();
-
-
- // Step 2. Initalize GPIO:
- // This example function is found in the DSP2833x_Gpio.c file and
- // illustrates how to set the GPIO to it's default state.
- // InitGpio();
- // Setup only the GP I/O only for I2C functionality
-
- // Step 3. Clear all interrupts and initialize PIE vector table:
- // Disable CPU interrupts
- DINT;
-
- // Initialize PIE control registers to their default state.
- // The default state is all PIE interrupts disabled and flags
- // are cleared.
- // This function is found in the DSP2833x_PieCtrl.c file.
- InitPieCtrl();
-
- // Disable CPU interrupts and clear all CPU interrupt flags:
- IER = 0x0000;
- IFR = 0x0000;
-
- // Initialize the PIE vector table with pointers to the shell Interrupt
- // Service Routines (ISR).
- // This will populate the entire table, even if the interrupt
- // is not used in this example. This is useful for debug purposes.
- // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
- // This function is found in DSP2833x_PieVect.c.
- InitPieVectTable();
-
- // Interrupts that are used in this example are re-mapped to
- // ISR functions found within this file.
-
- Init_Port();
- // Step 4. Initialize all the Device Peripherals:
- // This function is found in DSP2833x_InitPeripherals.c
- // InitPeripherals(); // Not required for this example
-
- // Step 5. User specific code
-
-
-
- // Enable interrupts required for this example
-
-
- // Enable CPU INT8 which is connected to PIE group 8
-
- EINT; // Enable Global interrupt INTM
-
- for(;;)
- {
- Lcd_12864_Test();
- } // end of for(;;)
- //#endif
- } // end of main
-
-
-
-
-
-
- //===========================================================================
- // No more.
- //===========================================================================
复制代码
|
|