TI中文支持网
TI专业的中文技术问题搜集分享网站

TM4C1294 EEProm读写问题

各位大侠:

        我在调试TM4C1294的Eeprom读写问题,一直都没有调通,哪位高手指点一下!

        时钟配置:

        

g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                                                          SYSCTL_OSC_MAIN |
                                                                          SYSCTL_USE_PLL |
                                                                          SYSCTL_CFG_VCO_480), 120000000);

        代码如下:        

        SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
        EEPROMInit();
        e2prodata.E2romFlg = 0x0555;
        EEPROMProgram((uint32_t*)(e2prodata.E2romFlg), EEPROM_BASE_ADDRESS, 4);
        e2prodata.E2romFlg = 0;
        EEPROMRead((uint32_t*)(e2prodata.E2romFlg) ,EEPROM_BASE_ADDRESS, 4);
        if(e2prodata.E2romFlg == 0x0555)
        {
               UARTprintf("Eeprom Read and write succeed.\n");
        }
       else if(e2prodata.E2romFlg == 0)
       {
               UARTprintf("Eeprom Read and write failed.\n");
       }

       感谢了!

xyz549040622:

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_ints.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/eeprom.h"
#include "utils/uartstdio.h"#define E2PROM_TEST_ADRES 0x0000struct E2PROM
{uint8_t value1;uint8_t value2;uint16_t value3;uint8_t value4[12];
};struct E2PROM e2prom_write_value = {5,7,9826, "Hello World"}; /* Write struct */
struct E2PROM e2prom_read_value ={0,0,0,""}; /* Read struct */int main(void){uint32_t e2size,e2block;SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); // islemcimizi 80 Mhz'e ayarlıyoruz./* UART SETTINGS */SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);GPIOPinConfigure(GPIO_PA0_U0RX);GPIOPinConfigure(GPIO_PA1_U0TX);GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);UARTStdioConfig(GPIO_PORTA_BASE,115200,SysCtlClockGet());/*******************************//* EEPROM SETTINGS */SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0); // EEPROM activateEEPROMInit(); // EEPROM start/*******************************/UARTprintf("EEPROM Test Program ,, Teknikyazi.com\r\n");e2size = EEPROMSizeGet(); // Get EEPROM SizeUARTprintf("EEPROM Size %d bytes\n", e2size);e2block = EEPROMBlockCountGet(); // Get EEPROM Block CountUARTprintf("EEPROM Blok Count: %d\n", e2block);UARTprintf("Write Try > Address %u: Struct : {%u,%u,%u,%s}\n", E2PROM_TEST_ADRES, e2prom_write_value.value1, e2prom_write_value.value2, e2prom_write_value.value3, e2prom_write_value.value4);EEPROMProgram((uint32_t *)&e2prom_write_value, E2PROM_TEST_ADRES, sizeof(e2prom_write_value)); //Write struct to EEPROM start from 0x0000EEPROMRead((uint32_t *)&e2prom_read_value, E2PROM_TEST_ADRES, sizeof(e2prom_read_value)); //Read from struct at EEPROM start from 0x0000UARTprintf("Read Try > Address %u: Struct : {%u,%u,%u,%s}\n", E2PROM_TEST_ADRES, e2prom_read_value.value1, e2prom_read_value.value2, e2prom_read_value.value3, e2prom_read_value.value4);while(1){}}

找到一个例程,你可以参考看看。你是卡在哪一步了呢?你eeprom的地址是否正确。

Michael Chen41:

回复 xyz549040622:

好的,谢谢了!

Michael Chen41:

回复 xyz549040622:

 xyz549040622 :
     您好!如果我要改成120MHz是在这里改吗?

SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); // islemcimizi 80 Mhz'e ayarlıyoruz.

Thanks and Best regards
Michael

Michael Chen41:

回复 xyz549040622:

测试OK的,谢谢了!

赞(0)
未经允许不得转载:TI中文支持网 » TM4C1294 EEProm读写问题
分享到: 更多 (0)