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

BB-Black入门

1、中国版BB-Black硬件资源

2、BB-Black开发环境搭建

 

入门:http://beagleboard.org/Getting%20Started

CCS linux版本下载:http://processors.wiki.ti.com/index.php/Download_CCS

VMware Tools安装:

3、连接调试

方法一:使用SecrueCRT连接调试

1)      安装SecureCRT软件,SecureCRT是一款不错的工具,大家可以下载绿色版使用,或者按照下列的信息填写“许可向导”完成注册。

名字:Windows

公司:IC

序列号:03-50-006248

许可密钥:ADPUSB W3DQ5B ZC35EJ 99AG3T ACM47V SAK5W6 8CD1YZ GJU7JK

发布日期:27-06-2006

2)  打开后输入BB的地址192.168.7.2,协议选SSH2,前提是给BB上电并连接好网线

3)      输入用户名Root

4)      口令默认为空

5) 点击确定,就连接上BB-Black了,接下来就可以调试了

方法二:串口连接调试

BB-Black板卡上提供了调试串口,为了能在PC机上调试,我们需要一个RS232模块和一个串口线或一个USB转串口线。其中PIN1为GND,PIN4为RX,PIN5为TX,TTL转RS232模块的TTL端接BB-Black的调试串口,另一端与PC机相连。

2) 为了方便,我们还是基于上面使用的SecureCRT讲解,点击“连接”弹出连接对话框,点击“New Session”,然后选择Serial继续“下一步”,设置好端口和波特率,点击“下一步”、“完成”、“连接”。

 

3)给BB-Black上电就可以打印信息了。相关设置如下:

4、相关帖子链接

1)      虚拟机下Ubuntu10.04自带有gcc(http://www.deyisupport.com/question_answer/dsp_arm/omap_l1x/f/54/t/70303.aspx)

2)      相关资料分享(http://www.deyisupport.com/question_answer/dsp_arm/sitara_arm/f/25/t/11199.aspx)

3)      ti-sdk-am335x-evm-07.00.00.00-Linux-x86-Install.bin安装

(http://www.deyisupport.com/question_answer/dsp_arm/sitara_arm/f/25/t/73468.aspx)

mangui zhang:

Word版资料请查看附件。

mangui zhang:

回复 mangui zhang:

Symbol for AM335x:

http://www.ti.com/product/am3359#symbols

Other Support Links

AM335x Wiki Page
AM335x Product Selection Guide
AM335x Android Guide
AM335x Linux Software Developer’s Guide
AM335x HW Design Guide
AM335x Forums

For EVM schematic and PCB Layout.– Beaglebone http://beagleboard.org/hardware/design/– Beaglebone-Black http://beagleboard.org/Products/BeagleBone%20Black– GP EVM http://www.ti.com/tool/tmdxevm3358– StarterKit http://www.ti.com.cn/tool/cn/tmdssk3358

Hardware Design Guide• Schematic & PCB layout checklist– http://processors.wiki.ti.com/index.php/AM335x_Schematic_Checklist– http://processors.wiki.ti.com/index.php/AM335x_Layout_Checklist• DDR2/3 design & layout guide– More detail in AM335x Datasheet.• Multiple options to choose Power management Chips based on CostFeature requirements.– http://processors.wiki.ti.com/index.php/Device:AM335x:Device_Evaluation#Power

Power Solution for AM355x• We have provided power-consumption summary– http://processors.wiki.ti.com/index.php/AM335x_Power_Consumption_Summary• Power Estimation Tool– http://processors.wiki.ti.com/index.php/AM335x_Power_Estimation_Tool

Hardware Migration Guide• AM37x to AM335x Hardware Migration Guide– http://processors.wiki.ti.com/index.php/AM37x_To_AM335x_Hardware_Migration_Guide• AM35x to AM335x Hardware Migration Guide– http://processors.wiki.ti.com/index.php/AM35x_To_AM335x_Hardware_Migration_Guide• AM18x to AM335x Hardware Migration Guide– http://processors.wiki.ti.com/index.php/AM18x_To_AM335x_Hardware_Migration_Guide• AM387x to AM335x Hardware Migration Guide– http://processors.wiki.ti.com/index.php/AM387x_To_AM335x_Hardware_Migration_Guide

 

da qin zheng sheng:

很强大啊!

mangui zhang:

回复 mangui zhang:

RTC模块为设备提供一个长的记时模式。基本上是每秒一次。时间可以设定为 12 或 24 小时模式 。时间寄存器有缓冲区,不会因为更改设定值而影响记时的准确性。而且可以设置中断来响应CPU事件,在某一特定的时间间隔如每分钟或每天中断一次。可编程的记时周期等,对它的寄存器定义我们可以查看库的RTC.h头文件。       使用RTC模块的步骤:1、 为 RTC 配置主系统时钟。如果需要,需要开启其端口的多路复用功能。2、RTC 寄存器一般是写保护的。若要禁用此写保护,编程 RTC 寄存器,必须写入一个特定值到KICK寄存器 (KICK0 和 KICK1)。要执行此操作可以使用 RTCWriteProtectDisable() 这个 API函数。3、调用 RTC32KClkSourceSelect() API 函数传递相应的参数,以选择使用内部时钟源或提供 32 KHz 时钟 的外部时钟源。我们的开发板就是外接的32K时钟,如下图所示4、调用 RTC32KClkClockControl() API函数传递适当的参数以使能 RTC选择从上一部选定的时钟源输入。5、调用 RTCEnable() 来启用 RTC模块。这可确保输入到 RTC 的 32 KHz 时钟有效。6、我们可以使用 RTCTimeSet() 函数来设定时间。我们要设定的时间作为一个参数传递给此函数。此函数设置有关寄存器如分钟、 小时、 AM 或 PM。也有 单独的API函数设置这些值。7、调用 RTCRun() 后应立即调用 API RTCTimeSet() 来启动时钟,这样可以减少误差。8、使用 RTCCalendarSet() 可以设置指定的日期信息。日期信息作为一个参数传递给此函数。此函数设置天、 月份和年份值。也有 Api 来单独设置这些值。9、可以通过调用 RTCTimeGet() 和 RTCCalendarGet() 从有关寄存器分别读取当前时间和日期信息。10、用户还可以使能在发生特定事件时产生中断。使用 RTCIntTimerEnable() 启用中断。中断事件可以是一秒、 分钟、 小时或一天。11、RTC模块也可以在它达到一定的时间或读取日期时生成中断。这些称为报警中断,如果想启用它们使用 RTCIntAlarmEnable() 函数将报警时间写入 RTC 的报警寄存器。从以上说明可见RTC模块的强大,完全可以作为一个全功能的时钟使用。下面这份例程运行时在串口要求用户输入时间和日期,并把他们写入RTC相关寄存器,然后就会在串口同步显示出当前日期信息

#include "evmskAM335x.h"
#include "soc_AM335x.h"
#include "interrupt.h"
#include "uartStdio.h"
#include "cache.h"
#include "rtc.h"
#include "mmu.h"

/*****************************************************************************
**                 INTERNAL MACRO DEFINITIONS
*****************************************************************************/

#define MASK_HOUR               (0xFF000000u)
#define MASK_MINUTE             (0x00FF0000u)
#define MASK_SECOND             (0x0000FF00u)
#define MASK_MERIDIEM           (0x000000FFu)

#define HOUR_SHIFT              (24u)
#define MINUTE_SHIFT            (16u)
#define SECOND_SHIFT            (8u)

#define MASK_DAY                (0xFF000000u)
#define MASK_MONTH              (0x00FF0000u)
#define MASK_YEAR               (0x0000FF00u)
#define MASK_DOTW               (0x000000FFu)

#define DAY_SHIFT               (24u)
#define MONTH_SHIFT             (16u)
#define YEAR_SHIFT              (8u)

#define RTC_INST_BASE           (SOC_RTC_0_REGS)
#define RTC_INT_NUM             (SYS_INT_RTCINT)

/* Definitions related to MMU Configuration. */
#define START_ADDR_DDR          (0x80000000u)
#define START_ADDR_DEV          (0x44000000u)
#define START_ADDR_OCMC         (0x40300000u)
#define NUM_SECTIONS_DDR        (512u)
#define NUM_SECTIONS_DEV        (960u)
#define NUM_SECTIONS_OCMC       (1u)

/******************************************************************************
**                 INTERNAL FUNCTION PROTOTYPES
******************************************************************************/

static void CalendarResolve(unsigned int calendarValue);
static unsigned char ASCIIToInt(unsigned char byte);
static unsigned int IntToASCII(unsigned char byte);
static void TimeResolve(unsigned int timeValue);
static unsigned int UserCalendarInfoGet(void);
static unsigned int UserTimeInfoGet(void);
static void MMUConfigAndEnable(void);
static void RTCINTCConfigure(void);
static void RTCIsr(void);

/******************************************************************************
**                 INTERNAL VARIABLE DEFINITIONS
******************************************************************************/

/* Page tables start must be aligned in 16K boundary */
#ifdef __TMS470__
#pragma DATA_ALIGN(pageTable, MMU_PAGETABLE_ALIGN_SIZE);
static volatile unsigned int pageTable[MMU_PAGETABLE_NUM_ENTRY];

#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment=MMU_PAGETABLE_ALIGN_SIZE
static volatile unsigned int pageTable[MMU_PAGETABLE_NUM_ENTRY];

#elif defined(gcc)
static volatile unsigned int pageTable[MMU_PAGETABLE_NUM_ENTRY]
__attribute__((aligned(MMU_PAGETABLE_ALIGN_SIZE)));

#else
#error "Unsupported Compiler. \r\n"

#endif

/******************************************************************************
**                 INTERNAL FUNCTION DEFINITIONS
******************************************************************************/

/*
** This function will setup the MMU. The function maps three regions –
** 1. DDR
** 2. OCMC RAM
** 3. Device memory
** The function also enables the MMU.
*/
static void MMUConfigAndEnable(void)
{
    /*
    ** Define DDR memory region of AM335x. DDR can be configured as Normal
    ** memory with R/W access in user/privileged modes. The cache attributes
    ** specified here are,
    ** Inner – Write through, No Write Allocate
    ** Outer – Write Back, Write Allocate
    */
    REGION regionDdr = {
                        MMU_PGTYPE_SECTION, START_ADDR_DDR, NUM_SECTIONS_DDR,
                        MMU_MEMTYPE_NORMAL_NON_SHAREABLE(MMU_CACHE_WT_NOWA,
                                                         MMU_CACHE_WB_WA),
                        MMU_REGION_NON_SECURE, MMU_AP_PRV_RW_USR_RW,
                        (unsigned int*)pageTable
                       };
    /*
    ** Define OCMC RAM region of AM335x. Same Attributes of DDR region given.
    */
    REGION regionOcmc = {
                         MMU_PGTYPE_SECTION, START_ADDR_OCMC, NUM_SECTIONS_OCMC,
                         MMU_MEMTYPE_NORMAL_NON_SHAREABLE(MMU_CACHE_WT_NOWA,
                                                          MMU_CACHE_WB_WA),
                         MMU_REGION_NON_SECURE, MMU_AP_PRV_RW_USR_RW,
                         (unsigned int*)pageTable
                        };

    /*
    ** Define Device Memory Region. The region between OCMC and DDR is
    ** configured as device memory, with R/W access in user/privileged modes.
    ** Also, the region is marked 'Execute Never'.
    */
    REGION regionDev = {
                        MMU_PGTYPE_SECTION, START_ADDR_DEV, NUM_SECTIONS_DEV,
                        MMU_MEMTYPE_DEVICE_SHAREABLE,
                        MMU_REGION_NON_SECURE,
                        MMU_AP_PRV_RW_USR_RW  | MMU_SECTION_EXEC_NEVER,
                        (unsigned int*)pageTable
                       };

    /* Initialize the page table and MMU */
    MMUInit((unsigned int*)pageTable);

    /* Map the defined regions */
    MMUMemRegionMap(®ionDdr);
    MMUMemRegionMap(®ionOcmc);
    MMUMemRegionMap(®ionDev);

    /* Now Safe to enable MMU */
    MMUEnable((unsigned int*)pageTable);
}

/*
** Main function.
*/
int main(void)
{
    unsigned int userCalendar = 0;
    unsigned int userTime = 0;

    /* Configure and enable the MMU. */
    MMUConfigAndEnable();

    /* Enable all levels of Cache. */
    CacheEnable(CACHE_ALL);
   
    /* Configuring the UART STDIO instance. */
    UARTStdioInit();

    /* Performing the System Clock configuration for RTC. */
    RTCModuleClkConfig();
   
    /* Disabling Write Protection for RTC registers.*/
    RTCWriteProtectDisable(RTC_INST_BASE);

    /* Selecting Internal Clock source for RTC. */
    RTC32KClkSourceSelect(RTC_INST_BASE, RTC_INTERNAL_CLK_SRC_SELECT);

    /* Enabling RTC to receive the Clock inputs. */
    RTC32KClkClockControl(RTC_INST_BASE, RTC_32KCLK_ENABLE);

    /* Enable the RTC module. */
    RTCEnable(RTC_INST_BASE);

    UARTPuts("StarterWare AM335x RTC Application.\r\n", -2);

    /* Receiving Time related information from the user. */
    userTime = UserTimeInfoGet();

    /* Receiving Calendar related information from the user. */
    userCalendar = UserCalendarInfoGet();
   
    /* Programming calendar information in the Calendar registers. */
    RTCCalendarSet(RTC_INST_BASE, userCalendar);

    /* Programming the time information in the Time registers. */
    RTCTimeSet(RTC_INST_BASE, userTime);
   
    /* Set the 32KHz counter to run. */
    RTCRun(RTC_INST_BASE);

    UARTPuts("\r\n\r\n", -2);
    UARTPuts("Current Time And Date:\r\n", -1);

    /* Enabling IRQ in CPSR of ARM processor. */
    IntMasterIRQEnable();

    /* Configure the AINTC to receive RTC interrupts. */
    RTCINTCConfigure();

    /* Enabling RTC interrupts. Configuring RTC to interrupt every second.*/
    RTCIntTimerEnable(RTC_INST_BASE, RTC_INT_EVERY_SECOND);

    while(1);
}

/*
** This function receives time related information from the user.
*/
static unsigned int UserTimeInfoGet()
{
    unsigned char minute[2] = {0};
    unsigned char second[2] = {0};
    unsigned char hour[2] = {0};
    unsigned int hourTime = 0;
    unsigned int minTime = 0;
    unsigned int secTime = 0;
    unsigned int lIndex = 0;
    unsigned int time = 0;

    UARTPuts("\nEnter the time in 24 hour format.\r\n", -1);
    UARTPuts("Example (hh:mm:ss) 20:15:09\r\n", -1);

    UARTPuts("\r\nEnter Hours: \r\n", -2);

    /*
    ** Collecting the 'Hour' information. The values collected shall be in
    ** the ASCII form of the numbers entered.
    */
    do
    {
        hour[lIndex] = UARTGetc();
        UARTPutc(hour[lIndex]);
        lIndex++;
    }while((lIndex < 2) && (hour[lIndex – 1] != '\r'));

    UARTPuts("\r\nEnter Minutes:\r\n", -2);
    lIndex = 0;

    /*
    ** Collecting the 'Minute' information. The values collected shall be in
    ** the ASCII form of the numbers entered.
    */
    do
    {
        minute[lIndex] = UARTGetc();
        UARTPutc(minute[lIndex]);
        lIndex++;
    }while((lIndex < 2) && (minute[lIndex – 1] != '\r'));

    UARTPuts("\r\nEnter Seconds:\r\n", -1);
    lIndex = 0;

    /*
    ** Collecting the 'Second' information. The values collected shall be in
    ** the ASCII form of the numbers entered.
    */
    do
    {
        second[lIndex] = UARTGetc();
        UARTPutc(second[lIndex]);
        lIndex++;
    }while((lIndex < 2) && (second[lIndex – 1] != '\r'));

    /* Converting the ASCII value of 'Hours' to its equivalent decimal value. */
    if(hour[0] != '\r')
    {
        hourTime = (ASCIIToInt(hour[0]) << 0x04);
        if(hour[1] != '\r')
        {
            hourTime |= ASCIIToInt(hour[1]);
        }
        else
        {
            hourTime = hourTime >> 0x04;
        }
    }

    /* Converting the ASCII value of 'Minutes' to its equivalent decimal value. */
    if(minute[0] != '\r')
    {
        minTime = (ASCIIToInt(minute[0]) << 0x04);
        if(minute[1] != '\r')
        {
            minTime |= ASCIIToInt(minute[1]);
        }
        else
        {
            minTime = minTime >> 0x04;
        }
    }

    /* Converting the ASCII value of 'Seconds' to its equivalent decimal value. */
    if(second[0] != '\r')
    {
        secTime = (ASCIIToInt(second[0]) << 0x04);
        if(second[1] != '\r')
        {
            secTime |= ASCIIToInt(second[1]);
        }
        else
        {
            secTime = secTime >> 0x04;
        }
    }

    /*
    ** Consolidating the decimal values of Hours, Minutes and Seconds to
    ** obtain the Time.
    */
    time = (hourTime << HOUR_SHIFT);
    time |= (minTime << MINUTE_SHIFT);
    time |= (secTime << SECOND_SHIFT);

    return time;
}

/*
** This function receives calendar related information from the user.
*/
static unsigned int UserCalendarInfoGet()
{
    unsigned char monthArr[2] = {0};
    unsigned char yearArr[2] = {0};
    unsigned char dotwArr[2] = {0};
    unsigned char dayArr[2] = {0};
    unsigned int calendar = 0;
    unsigned int lIndex = 0;
    unsigned int month = 0;
    unsigned int year = 0;
    unsigned int dotw = 0;
    unsigned int day = 0;

    UARTPuts("\r\n\r\nEnter the calendar information.\r\n", -2);
    UARTPuts("Example (DD:MM:YY) 31:03:73\r\n", -2);
   
    UARTPuts("\r\nEnter the day of the month: \r\n", -2);
   
    /*
    ** Collecting the 'Day of the Month' information. The values collected
    ** shall be in the ASCII form of the numbers entered.
    */
    do
    {
        dayArr[lIndex] = UARTGetc();
        UARTPutc(dayArr[lIndex]);
        lIndex++;
    }while((lIndex < 2) && (dayArr[lIndex – 1] != '\r'));

    UARTPuts("\r\nEnter the month (Jan=01, Dec=12):\r\n", -2);
    lIndex = 0;

    /*
    ** Collecting the 'Month' information. The values collected
    ** shall be in the ASCII form of the numbers entered.
    */
    do
    {
        monthArr[lIndex] = UARTGetc();
        UARTPutc(monthArr[lIndex]);
        lIndex++;        
    }while((lIndex < 2) && (monthArr[lIndex – 1] != '\r'));

    UARTPuts("\r\nEnter the year (Ex: 2010=10, 1987=87:):\r\n", -1);
    lIndex = 0;

    /*
    ** Collecting the 'Year' information. The values collected
    ** shall be in the ASCII form of the numbers entered.
    */
    do
    {
        yearArr[lIndex] = UARTGetc();
        UARTPutc(yearArr[lIndex]);
        lIndex++;
    }while((lIndex < 2) && (yearArr[lIndex – 1] != '\r'));

    UARTPuts("\r\nEnter the Day of the Week (Ex:Sun=00, Sat=06):\r\n", -3);
    lIndex = 0;

    /*
    ** Collecting the 'Day of the Week' information. The values collected
    ** shall be in the ASCII form of the numbers entered.
    */
    do
    {
        dotwArr[lIndex] = UARTGetc();
        UARTPutc(dotwArr[lIndex]);
        lIndex++;
    }while((lIndex < 2) && (dotwArr[lIndex – 1] != '\r'));

    /*
    ** Converting the ASCII value of 'Day of the Month' to its equivalent
    ** decimal value.
    */
    if(dayArr[0] != '\r')
    {
        day = (ASCIIToInt(dayArr[0]) << 0x04);
        if(dayArr[1] != '\r')
        {
            day |= ASCIIToInt(dayArr[1]);
        }
        else
        {
            day = day  >> 0x04;
        }
    }

    /* Converting the ASCII value of 'Month' to its equivalent decimal value. */
    if(monthArr[0] != '\r')
    {
        month = (ASCIIToInt(monthArr[0]) << 0x04);
        if(monthArr[1] != '\r')
        {
            month |= ASCIIToInt(monthArr[1]);
        }
        else
        {
            month = month >> 0x04;
        }
    }

    /* Converting the ASCII value of 'Year' to its equivalent decimal value. */
    if(yearArr[0] != '\r')
    {
        year = (ASCIIToInt(yearArr[0]) << 0x04);
        if(yearArr[1] != '\r')
        {
            year |= ASCIIToInt(yearArr[1]);
        }
        else
        {
            year = year >> 0x04;
        }
    }

    /*
    ** Converting the ASCII value of 'Day of the Week' to its equivalent
    ** decimal value.
    */
    if(dotwArr[0] != '\r')
    {
        dotw = (ASCIIToInt(dotwArr[0]) << 0x04);
        if(dotwArr[1] != '\r')
        {
            dotw |= ASCIIToInt(dotwArr[1]);
        }
        else
        {
            dotw = dotw >> 0x04;
        }
    }

    /*
    ** Consolidating the decimal values of Day of the Month, Month, Year
    ** and Day of the Week to obtain the Date.
    */
    calendar =  day << DAY_SHIFT;     
    calendar |= month << MONTH_SHIFT;
    calendar |= year << YEAR_SHIFT;
    calendar |= dotw;

    return calendar;
}  

/*
** This function prints the current time read from the RTC registers.
*/
static void TimeResolve(unsigned int timeValue)
{
    unsigned char timeArray[3] = {0};              
    unsigned char bytePrint[2] = {0};
    unsigned int asciiTime = 0;
    unsigned int lIndex = 0;
    unsigned int count = 0;
   
    /*
    ** The variable 'timeValue' will have the time in the format
    ** . Now, obtaining the individual fields    ** to facilitate their display.
    */
    timeArray[0] = (unsigned char)((timeValue & MASK_HOUR) >> HOUR_SHIFT);
    timeArray[1] = (unsigned char)((timeValue & MASK_MINUTE) >> MINUTE_SHIFT);
    timeArray[2] = (unsigned char)((timeValue & MASK_SECOND) >> SECOND_SHIFT);

    /* Prints the time in the format: . */    while(count < 3)
    {
        lIndex = 0;
        asciiTime = IntToASCII(timeArray[count]);
        bytePrint[0] = (unsigned char)((asciiTime & 0x0000FF00) >> 0x08);
        bytePrint[1] = (unsigned char)(asciiTime & 0x000000FF);
        while(lIndex < 2)
        {   
            UARTPutc(bytePrint[lIndex]);
            lIndex++;
        }
        count++;
        if(count != 3)
        {
            UARTPutc(':');
        }
        else
        {
            UARTPutc(' ');
        }
    }
}

/*
** This function prints the calendar information read from the RTC registers.
*/
static void CalendarResolve(unsigned int calendarValue)
{
    unsigned char calendarArray[3] = {0};
    unsigned char dotwString[4] = {0};
    unsigned char bytePrint[2] = {0};
    unsigned int asciiCalendar = 0;
    unsigned int dotwValue = 0;
    unsigned int lIndex = 0;
    unsigned int count = 0;

    /*
    ** The variable 'calendarValue' will have the date in the format
    ** . Now, obtaining the individual fields    ** to facilitate their display.
    */
    calendarArray[0] = (unsigned char)((calendarValue & MASK_DAY) >> DAY_SHIFT);
    calendarArray[1] = (unsigned char)((calendarValue & MASK_MONTH) >> MONTH_SHIFT);
    calendarArray[2] = (unsigned char)((calendarValue & MASK_YEAR) >> YEAR_SHIFT);

    dotwValue = (calendarValue & MASK_DOTW);

    switch(dotwValue)
    {
        case 0x00:
             dotwString[0] = 'S';
             dotwString[1] = 'u';
             dotwString[2] = 'n';
             dotwString[3] = '\0';
        break;

        case 0x01:
             dotwString[0] = 'M';
             dotwString[1] = 'o';
             dotwString[2] = 'n';
             dotwString[3] = '\0';
        break;

        case 0x02:
             dotwString[0] = 'T';
             dotwString[1] = 'u';
             dotwString[2] = 'e';
             dotwString[3] = '\0';
        break;

        case 0x03:
             dotwString[0] = 'W';
             dotwString[1] = 'e';
             dotwString[2] = 'd';
             dotwString[3] = '\0';
        break;

        case 0x04:
             dotwString[0] = 'T';
             dotwString[1] = 'h';
             dotwString[2] = 'u';
             dotwString[3] = '\0';
        break;

        case 0x05:
             dotwString[0] = 'F';
             dotwString[1] = 'r';
             dotwString[2] = 'i';
             dotwString[3] = '\0';
        break;

        case 0x06:
             dotwString[0] = 'S';
             dotwString[1] = 'a';
             dotwString[2] = 't';
             dotwString[3] = '\0';

        default:
        break;
    }
   
    /* Prints the date in the format: . */    while(count < 3)
    {
        lIndex = 0;
        asciiCalendar = IntToASCII(calendarArray[count]);
        bytePrint[0] = (unsigned char)((asciiCalendar & 0x0000FF00) >> 0x08);
        bytePrint[1] = (unsigned char)(asciiCalendar & 0x000000FF);
        while(lIndex < 2)
        {
            UARTPutc(bytePrint[lIndex]);
            lIndex++;
        }
        count++;
        if(count != 3)
        {
            UARTPutc('-');
        }
        else
        {
            UARTPutc(' ');
        }
    }  
    UARTPuts((char *)dotwString, -2);
}

/*
** This function converts the nibbles of an 8-bit number to their ASCII
** equivalent value. The 8-bit number is passed as a parameter to this
** function.
** For Example, if a number 19 is given to this function, this function
** returns 0x3139. Here, 0x31 is the ASCII value of 1 and 0x39 is the
** ASCII value of 9.
*/
static unsigned int IntToASCII(unsigned char byte)
{
    unsigned char highNibble = 0;
    unsigned char lowNibble = 0;
    unsigned int retVal = 0;

    lowNibble = (byte & 0x0F);
    highNibble = (byte & 0xF0) >> 0x04;

    retVal = (lowNibble + 0x30);
    retVal |= ((highNibble + 0x30) << 0x08);

    return retVal;
}

/*
** This function converts the ASCII value of a hexadecimal number to its
** corresponding hexadecimal value.
*/
static unsigned char ASCIIToInt(unsigned char byte)
{
    unsigned char retVal = 0;

    /* For numbers from 0x0 to 0x9.*/
    if((byte >= 0x30) && (byte <= 0x39))
    {
        retVal = byte – 0x30;
    }
    /* For alphabets from A to F.*/
    else if((byte >= 0x41) && (byte <= 0x46))
    {
        retVal = byte – 0x37;
    }
   
    return retVal;
}

/*
** This function configures the Interrupt Controller(INTC) to receive
** RTC interrupts.
*/
static void RTCINTCConfigure(void)
{
    /* Initializing the ARM Interrupt Controller. */
    IntAINTCInit();

    /* Registering the Interrupt Service Routine(ISR). */
    IntRegister(RTC_INT_NUM, RTCIsr);

    /* Setting the priority for the system interrupt in AINTC. */
    IntPrioritySet(RTC_INT_NUM, 0, AINTC_HOSTINT_ROUTE_IRQ);

    /* Enabling the system interrupt in AINTC. */
    IntSystemEnable(RTC_INT_NUM);   
}

/*
** This is the Interrupt Service Routine(ISR) for RTC.
*/
static void RTCIsr(void)
{
    unsigned int calendarValue = 0;   
    unsigned int timeValue = 0;
        
    /* Read the current time from RTC time registers. */
    timeValue = RTCTimeGet(RTC_INST_BASE);

    /* Decode the time in 'timeValue' and display it on console.*/
    TimeResolve(timeValue);

    /* Read the current date from the RTC calendar registers. */
    calendarValue = RTCCalendarGet(RTC_INST_BASE);
   
    UARTPuts("   ", -2);

    /* Decode  the date in 'calendarValue' and display it on console.*/
    CalendarResolve(calendarValue);

    UARTPuts("\r", -2);   
}

赞(0)
未经允许不得转载:TI中文支持网 » BB-Black入门
分享到: 更多 (0)