打印
[Atmel]

用ASF跑SAMD21程序(18)EEPROM

[复制链接]
1383|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
首先,新建ASF工程,然后加入EEPROM模块。


然后在ASF explorer中打开QUICK START GUIDE


按照上面步骤做,然后编译通过:


但下进去灯不亮,有断点才发现原来熔丝位没有设EEPROM段。究竟怎么原因,下回分解。

上程序先:

/**
* \file
*
* \brief Empty user application template
*
*/

/**
* \mainpage User Application template doxygen documentation
*
* \par Empty user application template
*
* This is a bare minimum user application template.
*
* For documentation of the board, go \ref group_common_boards "here" for a link
* to the board-specific documentation.
*
* \par Content
*
* -# Include the ASF header files (through asf.h)
* -# Minimal main function that starts with a call to system_init()
* -# Basic usage of on-board LED and button
* -# "Insert application code here" comment
*
*/

/*
* Include header files for all drivers that have been imported from
* Atmel Software Framework (ASF).
*/
#include <asf.h>
void configure_eeprom(void);

void configure_eeprom(void)
{   
         /* Setup EEPROM emulator service */
         enum status_code error_code = eeprom_emulator_init();
         if (error_code == STATUS_ERR_NO_MEMORY)
          {
                          while (true)
                                   {            /* No EEPROM section has been set in the device's fuses */        }   
           }
         else if (error_code != STATUS_OK)
         {        /* Erase the emulated EEPROM memory (assume it is unformatted or         * irrecoverably corrupt) */
                        eeprom_emulator_erase_memory();
                                 eeprom_emulator_init();    }}

int main (void)
{
        system_init();
        configure_eeprom();
       
         uint8_t page_data[EEPROM_PAGE_SIZE];
         eeprom_emulator_read_page(0, page_data);
         page_data[0] = !page_data[0];
         port_pin_set_output_level(LED_0_PIN, page_data[0]);
         eeprom_emulator_write_page(0, page_data);
         eeprom_emulator_commit_page_buffer();
          while (true) {    }

       
}

相关帖子

沙发
百能网PCB| | 2015-1-14 09:58 | 只看该作者

使用特权

评论回复
板凳
mcuzone| | 2015-1-14 11:20 | 只看该作者
版主很努力

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:http://shop34182318.taobao.com/ http://shop562064536.taobao.com

2398

主题

6945

帖子

66

粉丝