📄 main.c
字号:
// 669 IAP Library Demonstration Project
// Version 1.00 (18-Sep-2003)
// by A. Ayre
// (C) Embedded Systems Academy 2003
// Demonstrates some of the functions in the 669 In-Application Programming
// Library. Written for a device using a 20MHz crystal. Tested on a Phytec
// P89C51Rx2 PhyCORE module and Development Board
// To see the output, connect UART to PC COM Port and connect using
// a terminal program such as Hyperterm. Settings:
// 8-N-1, 9600 baud, no flow control
#include <stdio.h>
#include <reg51m.h>
#include "669iaplib.h"
// function uart_init
// initializes the UART to 8-N-1, 9600 baud @ 20MHz
void uart_init(void)
{
S0CON = 0x52; // mode 1, reception enable
T2CON |= 0x30;
BRGR0 = 0x13;
BRGR1 = 0x08;
BRGCON = 0x03; // use baud rate generator
}
void main(void)
{
uart_init();
printf("669 IAP Test\n");
printf("Manufacturer ID = %2.2bX\n", iap_read_manufacturer_id());
printf("Device ID 1 = %2.2bX\n", iap_read_device_id(1));
printf("Device ID 2 = %2.2bX\n", iap_read_device_id(2));
printf("Security bits = %2.2bX\n", iap_read_security_bits());
printf("0x004000 contains %2.2bX\n", iap_read_data_byte(0x4000, 0x00));
if (!iap_program_data_byte(0x55, 0x4000, 0x00))
printf("0x004000 programmed to 0x55 ok\n");
else
printf("Error programming 0x004000 to 0x55\n");
printf("0x004000 contains %2.2bX\n", iap_read_data_byte(0x4000, 0x00));
if (!iap_erase_block(BLOCK_2))
printf("Block 2 erased\n");
else
printf("Error erasing block 2\n");
printf("0x004000 contains %2.2bX\n", iap_read_data_byte(0x4000, 0x00));
printf("Boot Vector = %4.4X\n", iap_read_boot_vector());
printf("Status Byte = %2.2bX\n", iap_read_status_byte());
iap_program_security_bits(SECURITY_BIT_1);
printf("Programmed security bit 1\n");
printf("Security bits = %2.2bX\n", iap_read_security_bits());
iap_program_security_bits(SECURITY_BIT_2);
printf("Programmed security bit 2\n");
printf("Security bits = %2.2bX\n", iap_read_security_bits());
iap_program_security_bits(SECURITY_BIT_3);
printf("Programmed security bit 3\n");
printf("Security bits = %2.2bX\n", iap_read_security_bits());
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -