Hello !!
I would display video and in the some time print the current time in the terminal. For this I use videoloopback and rtc clock examples given in the drivers folder with C6748.
At the beginning when I used the two project. When the time is printed the video not work. So i said that i need to make 2 threads 1 for printing time ans 1 for displaying video.
For this i used the facedect project and i did many changes. At the begining the 2 threads work but when the interrupt of rtc clock began the stopped the thread of video display.
I think i need to enable the interrupt for rtc clock in the main but i don"t know how to do this. I'm a beginner in sys bios. Could anyone help me to resolve the problem.
I attached the project.
/* * facedetect_lcdk.c * * This file contains face detection demo code for LCDK. * * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * \file facedetect_lcdk.c * * \brief This file contains the face detection demo code for LCDK. * * This application captures the live camera input which is then * passed to the DSP. The DSP runs the face detection algorithm * provided by OpenCV and draws a rectangular box around the * detected face. The output is displayed over LCDC. * */ /* ========================================================================== */ /* INCLUDE FILES */ /* ========================================================================== */ #include <xdc/std.h> #include <xdc/runtime/Error.h> #include <xdc/runtime/System.h> #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Clock.h> #include <ti/sysbios/knl/Task.h> #include <ti/sysbios/knl/Semaphore.h> #include <ti/sysbios/family/c64p/Hwi.h> #include <stdio.h> #include "psc.h" #include "vpif.h" #include "raster.h" #include "interrupt.h" #include "lcdkC6748.h" #include "soc_C6748.h" #include "hw_psc_C6748.h" #include "adv7343.h" #include "tvp5147.h" #include "cdce913.h" #include "codecif.h" #include "i2cgpio.h" #include "string.h" #include "uartStdio.h" #include "uart.h" #include "rtc.h" /****************************************************************************** ** INTERNAL MACROS *******************************************************************************/ #define MSTPRI1 (0x01C14114) #define MSTPRI2 (0x01C14118) #define CAPTURE_IMAGE_WIDTH (720) #define CAPTURE_IMAGE_HEIGHT (576) #define DISPLAY_IMAGE_WIDTH (640) #define DISPLAY_IMAGE_HEIGHT (480) #define CLASSIFIER_CASCADE_SIZE (52519) #define REFERENCE_LOCATION_1 (0xC30011B0) #define REFERENCE_LOCATION_2 (0xC303464B) #define CV_DEFAULT_IMAGE_ROW_ALIGN (8) #define I2C_SLAVE_CODEC_ADV7343 (0x2Au) #define I2C_SLAVE_CODEC_TVP5147_1_SVIDEO (0x5Cu) #define I2C_SLAVE_CODEC_TVP5147_2_COMPOSITE (0x5Du) #define I2C_SLAVE_CDCE913 (0x65u) #define I2C_SLAVE_UI_EXPANDER (0x20u) #define INT_CHANNEL_I2C (0x2u) #define OFFSET1 ((CAPTURE_IMAGE_HEIGHT - DISPLAY_IMAGE_HEIGHT)/2) #define OFFSET2 ((CAPTURE_IMAGE_WIDTH - DISPLAY_IMAGE_WIDTH)/2) #define OFFSET (CAPTURE_IMAGE_WIDTH * OFFSET1 + OFFSET2) #define MASK_HOUR (0xFF000000u) #define MASK_MINUTE (0x00FF0000u) #define MASK_SECOND (0x0000FF00u) #define MASK_MERIDIEM (0x000000FFu) #define HOUR_SHIFT (24) #define MINUTE_SHIFT (16) #define SECOND_SHIFT (8) #define MASK_DAY (0xFF000000u) #define MASK_MONTH (0x00FF0000u) #define MASK_YEAR (0x0000FF00u) #define MASK_DOTW (0x000000FFu) #define DAY_SHIFT (24) #define MONTH_SHIFT (16) #define YEAR_SHIFT (8) /****************************************************************************** ** GLOBAL FUNCTION PROTOTYPES *******************************************************************************/ extern void cbcr422sp_to_rgb565_c(const unsigned char * restrict, unsigned int, unsigned int, const short*, const unsigned char *restrict, unsigned int, unsigned short *restrict, unsigned int, unsigned); /****************************************************************************** ** INTERNAL FUNCTION PROTOTYPES *******************************************************************************/ static void SetUpVPIFRx(void); static void SetUpLCD(void); 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 void Delay(volatile unsigned int count); static unsigned int UserCalendarInfoGet(void); static unsigned int UserTimeInfoGet(void); static void ConfigureIntRTC(void); static void SetupInt(void); static void RTCIsr(void); Void VPIFIsr(UArg arg); Void LCDIsr(UArg arg); Void colorconvertTask(UArg arg0, UArg arg1); Void facedetectTask(UArg arg0, UArg arg1); Void clockHandler(UArg arg); /****************************************************************************** ** INTERNAL VARIABLE DEFINITIONS *******************************************************************************/ unsigned int i,pingpong=1, buffcount=0, buffcount2, display_buff_1=0; int facedetect_complete=1, buffer_ready=0; volatile unsigned int changed=1, updated=3, processed=1; unsigned char *buff_luma[2], *buff_chroma[2]; unsigned char buff_luma1[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT]; unsigned char buff_luma2[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT]; unsigned char buff_chroma1[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT]; unsigned char buff_chroma2[CAPTURE_IMAGE_WIDTH * CAPTURE_IMAGE_HEIGHT]; unsigned char proc_buff_luma[DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT]; unsigned char *videoTopY, *videoTopC, *proc_buff_ptr; unsigned short *videoTopRgb1, *videoTopRgb2; unsigned short Rgb_buffer1[DISPLAY_IMAGE_WIDTH*DISPLAY_IMAGE_HEIGHT + 16]; unsigned short Rgb_buffer2[DISPLAY_IMAGE_WIDTH*DISPLAY_IMAGE_HEIGHT + 16]; const short ccCoeff[5] = {0x2000, 0x2BDD, -0x0AC5, -0x1658, 0x3770}; Semaphore_Handle sem1; Semaphore_Handle sem2; /****************************************************************************** ** FUNCTION DEFINITIONS *******************************************************************************/ Void main() { Hwi_Params params; Hwi_Handle Hwi1, Hwi2; Task_Params taskParams; Task_Handle task1, task2; Clock_Params clockParams; Clock_Handle Clk; Error_Block eb; /* Create a Semaphore object to be use as a resource lock */ sem1 = Semaphore_create(0, NULL, NULL); sem2 = Semaphore_create(0, NULL, NULL); /* Create the Color Convert Task */ Error_init(&eb); Task_Params_init(&taskParams); taskParams.priority = 1; taskParams.stackSize = 10000; task1 = Task_create(colorconvertTask, &taskParams, &eb); if (task1 == NULL) { System_printf("Task_create() failed for Color Conversion!\n"); BIOS_exit(0); } /* Create the FaceDetect Task*/ task2 = Task_create(facedetectTask, &taskParams, &eb); if (task2 == NULL) { System_printf("Task_create() failed for Face Detection!\n"); BIOS_exit(0); } /* Create the VPIF Interrupt*/ Hwi_Params_init(¶ms); params.eventId = 95; params.enableInt = FALSE; Hwi1 = Hwi_create(8, &VPIFIsr, ¶ms, &eb); if (Hwi1 == NULL) { System_printf("Hwi_create() failed for VPIF!\n"); BIOS_exit(0); } /* Create the LCDC Interrupt*/ Hwi_Params_init(¶ms); params.eventId = 73; params.enableInt = FALSE; Hwi2 = Hwi_create(9, &LCDIsr, ¶ms, &eb); if (Hwi2 == NULL) { System_printf("Hwi_create() failed for LCDC!\n"); BIOS_exit(0); } /* Create a clock that would go off every 1 Clock tick*/ Clock_Params_init(&clockParams); clockParams.period = 1; clockParams.startFlag = TRUE; Clk = Clock_create((Clock_FuncPtr)clockHandler, 4, &clockParams, &eb); if (Clk == NULL) { System_abort("Clock0 create failed"); } /* Setting the Master priority for LCD DMA controller to highest level */ *((volatile uint32_t *) MSTPRI2) = *((volatile uint32_t *) MSTPRI2) & 0x0FFFFFFF; BIOS_start(); /* enable interrupts and start SYS/BIOS */ } /* ** ClockHandler */ Void clockHandler(UArg arg) { /* Call Task_yield every 1 ms */ Task_yield(); } /* ** ColorconvertTask - This would color convert the captured frames and make it available for the LCDC display. ** Also, if the facedetect algorithm has finished working on the frame provided, it would provide a new frame. */ Void colorconvertTask(UArg a0, UArg a1) { /* Allocate pointers to buffers */ buff_luma[0] = buff_luma1; buff_luma[1] = buff_luma2; buff_chroma[0] = buff_chroma1; buff_chroma[1] = buff_chroma2; proc_buff_ptr = proc_buff_luma; /* Initializing palette for first buffer */ *Rgb_buffer1 = 0x4000; for (i = 1; i < 16; i++) *(Rgb_buffer1 +i) = 0x0000; videoTopRgb1 = Rgb_buffer1 + i; /* Initializing palette for second buffer */ *Rgb_buffer2 = 0x4000; for (i = 1; i < 16; i++) *(Rgb_buffer2 + i) = 0x0000; videoTopRgb2 = Rgb_buffer2 + i; /* Power on VPIF */ PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_VPIF, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); /* Initialize I2C and program UI GPIO expander, TVP5147, and ADV7343 via I2C */ I2CPinMuxSetup(0); /*Initialize the TVP5147 to accept composite video */ I2CCodecIfInit(SOC_I2C_0_REGS, INT_CHANNEL_I2C, I2C_SLAVE_CODEC_TVP5147_2_COMPOSITE); TVP5147CompositeInit(SOC_I2C_0_REGS); /* Setup VPIF pinmux */ VPIFPinMuxSetup(); /* Setup LCD */ SetUpLCD(); /* Initialize VPIF */ SetUpVPIFRx(); VPIFDMARequestSizeConfig(SOC_VPIF_0_REGS, VPIF_REQSIZE_ONE_TWENTY_EIGHT); VPIFEmulationControlSet(SOC_VPIF_0_REGS, VPIF_HALT); /* Initialize buffer addresses for 1st frame*/ VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int) buff_luma[0], CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_CHROMA, (unsigned int) buff_chroma[0], CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_LUMA, (unsigned int) (buff_luma[0] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_CHROMA, (unsigned int) (buff_chroma[0] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2); /* Configuring the base ceiling */ RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2, (unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2, (unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1); /* Enable interrupts */ Hwi_enable(); Hwi_enableInterrupt(8); Hwi_enableInterrupt(9); /* Enable capture */ VPIFCaptureChanenEnable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0); /* Enable VPIF interrupt */ VPIFInterruptEnable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0); VPIFInterruptEnableSet(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0); /* Enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* Enable raster */ RasterEnable(SOC_LCDC_0_REGS); buffcount++; buffcount2 = buffcount - 1; /* Run forever */ while (1) { /* Wait here till a new frame is not captured */ Semaphore_pend(sem1, BIOS_WAIT_FOREVER); /* Process the next buffer only when both the raster buffers * are pointing to the current buffer to avoid jitter effect */ Semaphore_pend(sem2, BIOS_WAIT_FOREVER); processed = 0; changed = 0; updated = 0; /* Convert the buffer from CBCR422 semi-planar to RGB565, * Set the flag for the buffer to be displayed on the LCD (which would be the processed buffer) * and notify the LCD of availability of a processed buffer. * The output buffers are ping-ponged each time. */ if (pingpong) { cbcr422sp_to_rgb565_c( (const unsigned char *) (videoTopC + OFFSET), DISPLAY_IMAGE_HEIGHT, CAPTURE_IMAGE_WIDTH, ccCoeff, (const unsigned char *) (videoTopY + OFFSET), CAPTURE_IMAGE_WIDTH, videoTopRgb1, DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_WIDTH); display_buff_1 = 1; } else { cbcr422sp_to_rgb565_c( (const unsigned char *) (videoTopC + OFFSET), DISPLAY_IMAGE_HEIGHT, CAPTURE_IMAGE_WIDTH, ccCoeff, (const unsigned char *) (videoTopY + OFFSET), CAPTURE_IMAGE_WIDTH, videoTopRgb2, DISPLAY_IMAGE_WIDTH, DISPLAY_IMAGE_WIDTH); display_buff_1 = 0; } pingpong = !pingpong; processed = 1; changed = 1; } } /* ** FacedetectTask - Runs the Face Detection Algorithm on the frame provided to it */ Void facedetectTask(UArg a0, UArg a1) { unsigned int UserTime = 0, UserCalendar = 0; UARTStdioInit(); RTCPinMuxSetup(FALSE); /* Disabling Write Protection for RTC registers.*/ RTCWriteProtectDisable(SOC_RTC_0_REGS); /* Performing a Software Reset and Enabling the RTC module. */ RTCEnable(SOC_RTC_0_REGS); /* Delay further operations by a minimum of three 32KHz clock times. */ Delay(0xFFFF); UARTPuts("StarterWare RTC Demo Application.\r\n", -2); UserTime = UserTimeInfoGet(); UserCalendar = UserCalendarInfoGet(); RTCCalendarSet(SOC_RTC_0_REGS, UserCalendar); RTCTimeSet(SOC_RTC_0_REGS, UserTime); RTCRun(SOC_RTC_0_REGS); UARTPuts("\r\n\r\n", -2); UARTPuts("Current Time And Date:\r\n", -1); /* Enabling interrupts.*/ SetupInt(); ConfigureIntRTC(); /* Enabling RTC interrupts. Configuring RTC to interrupt every second.*/ RTCIntTimerEnable(SOC_RTC_0_REGS, RTC_INT_EVERY_SECOND); } /* * Initialize capture */ static void SetUpVPIFRx(void) { /* Disable interrupts */ VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH1); VPIFInterruptDisable(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0); /* Disable capture ports */ VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_1); VPIFCaptureChanenDisable(SOC_VPIF_0_REGS, VPIF_CHANNEL_0); /* Interrupt after capturing the bottom field of every frame */ VPIFCaptureIntframeConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_FRAME_INTERRUPT_BOTTOM); /* Y/C interleaved capture over 8-bit bus */ VPIFCaptureYcmuxModeSelect(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_YC_MUXED); /* Capturing 480I (SD NTSC) */ //VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_480I, VPIF_CHANNEL_0, 0, (struct vbufParam *) 0); VPIFCaptureModeConfig(SOC_VPIF_0_REGS, VPIF_PAL, VPIF_CHANNEL_0, 0, (struct vbufParam *) 0); } /* * Configures raster to display image */ static void SetUpLCD(void) { PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_LCDC, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); LCDPinMuxSetup(); /* disable raster */ RasterDisable(SOC_LCDC_0_REGS); /* configure the pclk */ RasterClkConfig(SOC_LCDC_0_REGS, 25000000, 150000000); /* configuring DMA of LCD controller */ RasterDMAConfig(SOC_LCDC_0_REGS, RASTER_DOUBLE_FRAME_BUFFER, RASTER_BURST_SIZE_16, RASTER_FIFO_THRESHOLD_8, RASTER_BIG_ENDIAN_DISABLE); /* configuring modes(ex:tft or stn,color or monochrome etc) for raster controller */ RasterModeConfig(SOC_LCDC_0_REGS, RASTER_DISPLAY_MODE_TFT, RASTER_PALETTE_DATA, RASTER_COLOR, RASTER_RIGHT_ALIGNED); /* frame buffer data is ordered from least to Most significant bye */ RasterLSBDataOrderSelect(SOC_LCDC_0_REGS); /* disable nibble mode */ RasterNibbleModeDisable(SOC_LCDC_0_REGS); /* configuring the polarity of timing parameters of raster controller */ RasterTiming2Configure(SOC_LCDC_0_REGS, RASTER_FRAME_CLOCK_LOW | RASTER_LINE_CLOCK_LOW | RASTER_PIXEL_CLOCK_LOW | RASTER_SYNC_EDGE_RISING| RASTER_SYNC_CTRL_ACTIVE| RASTER_AC_BIAS_HIGH , 0, 255); /* configuring horizontal timing parameter */ RasterHparamConfig(SOC_LCDC_0_REGS, DISPLAY_IMAGE_WIDTH, 64, 48, 48); /* configuring vertical timing parameters */ RasterVparamConfig(SOC_LCDC_0_REGS, DISPLAY_IMAGE_HEIGHT, 2, 11, 31); /* configuring fifo delay to */ RasterFIFODMADelayConfig(SOC_LCDC_0_REGS, 2); } /* ** VPIF Interrupt service routine. */ Void VPIFIsr(UArg arg) { #ifdef _TMS320C6X IntEventClear(SYS_INT_VPIF_INT); #endif /* If previously captured frame is not processed, clear this interrupt and return */ if (!processed) { VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0); return; } /* buffcount represents buffer to be given to capture driver and * buffcount2 represents the newly captured buffer to be processed */ processed = 0; buffcount++; buffcount2 = buffcount - 1; // Currently only two buffers are being used for capture if (buffcount == 2) buffcount = 0; /* Initialize buffer addresses for a new frame*/ VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_LUMA, (unsigned int) buff_luma[buffcount], CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_TOP_FIELD, VPIF_CHROMA, (unsigned int) buff_chroma[buffcount], CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_LUMA, (unsigned int) (buff_luma[buffcount] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2); VPIFCaptureFBConfig(SOC_VPIF_0_REGS, VPIF_CHANNEL_0, VPIF_BOTTOM_FIELD, VPIF_CHROMA, (unsigned int) (buff_chroma[buffcount] + CAPTURE_IMAGE_WIDTH), CAPTURE_IMAGE_WIDTH*2); /* Initialize buffer addresses with the captured frame ready to be processed */ videoTopC = buff_chroma[buffcount2]; videoTopY = buff_luma[buffcount2]; /* clear interrupt */ VPIFInterruptStatusClear(SOC_VPIF_0_REGS, VPIF_FRAMEINT_CH0); Semaphore_post(sem1); } /* ** For each end of frame interrupt base and ceiling is reconfigured */ Void LCDIsr(UArg arg) { unsigned int status; #ifdef _TMS320C6X IntEventClear(SYS_INT_LCDC_INT); #endif /* Find which interrupt occurred and clear it */ status = RasterIntStatus(SOC_LCDC_0_REGS, RASTER_END_OF_FRAME0_INT_STAT | RASTER_END_OF_FRAME1_INT_STAT); status = RasterClearGetIntStatus(SOC_LCDC_0_REGS, status); if(!changed) return; /* Draw a rectangle from the detected sequence onto the current frame*/ /* Display the appropriate output buffer on the appropriate raster buffer * and if a new processed buffer is available, let the DSP know that * it has configured the raster buffer to point to the new output buffer * by updating the 'updated' flag */ if (display_buff_1) { if (status & RASTER_END_OF_FRAME0_INT_STAT) { RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1, (unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0); updated = updated | 0x1; } if (status & RASTER_END_OF_FRAME1_INT_STAT) { RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer1, (unsigned int) (Rgb_buffer1 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1); updated = updated | 0x2; } } else { if (status & RASTER_END_OF_FRAME0_INT_STAT) { RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2, (unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 0); updated = updated | 0x1; } if (status & RASTER_END_OF_FRAME1_INT_STAT) { RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int) Rgb_buffer2, (unsigned int) (Rgb_buffer2 + DISPLAY_IMAGE_WIDTH * DISPLAY_IMAGE_HEIGHT + 15), 1); updated = updated | 0x2; } } if(updated==3) { changed=0; Semaphore_post(sem2); } } static unsigned int UserTimeInfoGet() { unsigned char hour[2] = {0}, minute[2] = {0}, second[2] = {0}; unsigned int hourTime = 0, minTime = 0, secTime = 0; unsigned int time = 0; int i = 0; UARTPuts("\n\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); do { hour[i] = UARTGetc(); UARTPutc(hour[i]); i++; }while((i < 2) && (hour[i-1] != '\r')); UARTPuts("\r\nEnter Minutes:\r\n", -2); i = 0; do { minute[i] = UARTGetc(); UARTPutc(minute[i]); i++; }while((i < 2) && (minute[i-1] != '\r')); UARTPuts("\r\nEnter Seconds:\r\n", -1); i = 0; do { second[i] = UARTGetc(); UARTPutc(second[i]); i++; }while((i < 2) && (second[i-1] != '\r')); if(hour[0] != '\r') { hourTime = (ASCIIToInt(hour[0]) << 0x04); if(hour[1] != '\r') { hourTime |= ASCIIToInt(hour[1]); } else { hourTime = hourTime >> 0x04; } } if(minute[0] != '\r') { minTime = (ASCIIToInt(minute[0]) << 0x04); if(minute[1] != '\r') { minTime |= ASCIIToInt(minute[1]); } else { minTime = minTime >> 0x04; } } if(second[0] != '\r') { secTime = (ASCIIToInt(second[0]) << 0x04); if(second[1] != '\r') { secTime |= ASCIIToInt(second[1]); } else { secTime = secTime >> 0x04; } } 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 int calendar = 0; unsigned char dayOfMonth[2] = {0}, monthArr[2] = {0}, yearArr[2] = {0}; unsigned char dotwArr[2] = {0}; unsigned int dom = 0, month = 0, year = 0, dotw = 0; int j = 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); do { dayOfMonth[j] = UARTGetc(); UARTPutc(dayOfMonth[j]); j++; }while((j < 2) && (dayOfMonth[j-1] != '\r')); j = 0; UARTPuts("\r\nEnter the month (Jan=01, Dec=12):\r\n", -2); do { monthArr[j] = UARTGetc(); UARTPutc(monthArr[j]); j++; }while((j < 2) && (monthArr[j-1] != '\r')); j = 0; UARTPuts("\r\nEnter the year (Ex: 2010=10, 1987=87:):\r\n", -1); do { yearArr[j] = UARTGetc(); UARTPutc(yearArr[j]); j++; }while((j < 2) && (yearArr[j-1] != '\r')); j = 0; UARTPuts("\r\nEnter the Day of the Week (Ex:Sun=00, Sat=06):\r\n", -3); do { dotwArr[j] = UARTGetc(); UARTPutc(dotwArr[j]); j++; }while((j < 2) && (dotwArr[j-1] != '\r')); if(dayOfMonth[0] != '\r') { dom = (ASCIIToInt(dayOfMonth[0]) << 0x04); if(dayOfMonth[1] != '\r') { dom |= ASCIIToInt(dayOfMonth[1]); } else { dom = dom >> 0x04; } } if(monthArr[0] != '\r') { month = (ASCIIToInt(monthArr[0]) << 0x04); if(monthArr[1] != '\r') { month |= ASCIIToInt(monthArr[1]); } else { month = month >> 0x04; } } if(yearArr[0] != '\r') { year = (ASCIIToInt(yearArr[0]) << 0x04); if(yearArr[1] != '\r') { year |= ASCIIToInt(yearArr[1]); } else { year = year >> 0x04; } } if(dotwArr[0] != '\r') { dotw = (ASCIIToInt(dotwArr[0]) << 0x04); if(dotwArr[1] != '\r') { dotw |= ASCIIToInt(dotwArr[1]); } else { dotw = dotw >> 0x04; } } calendar = dom << 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 count = 0, i = 0; unsigned int asciiTime = 0; 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); while(count < 3) { i = 0; asciiTime = intToASCII(timeArray[count]); bytePrint[0] = (unsigned char)((asciiTime & 0x0000FF00) >> 0x08); bytePrint[1] = (unsigned char)(asciiTime & 0x000000FF); while(i < 2) { UARTPutc(bytePrint[i]); i++; } 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 int asciiCalendar = 0; unsigned int count = 0, j = 0; unsigned int dotwValue = 0; char bytePrint[2] = {0}; char dotwString[4] = {0}; 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; } while(count < 3) { j = 0; asciiCalendar = intToASCII(calendarArray[count]); bytePrint[0] = (char)((asciiCalendar & 0x0000FF00) >> 0x08); bytePrint[1] = (char)(asciiCalendar & 0x000000FF); while(j < 2) { UARTPutc(bytePrint[j]); j++; } count++; if(count != 3) { UARTPutc('-'); } else { UARTPutc(' '); } } UARTPuts(dotwString, -2); } /* ** This function converts a 8 bit number to its ASCII equivalent value. ** The 8 bit number is passed as a parameter to this function. */ static unsigned int intToASCII(unsigned char byte) { unsigned int retVal = 0; unsigned char lsn = 0, msn = 0; lsn = (byte & 0x0F); msn = (byte & 0xF0) >> 0x04; retVal = (lsn + 0x30); retVal |= ((msn + 0x30) << 0x08); return retVal; } /* ** This function converts the ASCII value of a hexadecimal number to its ** equivalent 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 Z.*/ else if((byte >= 0x41) && (byte <= 0x46)) { retVal = byte - 0x37; } return retVal; } /* ** This function invokes necessary functions to configure the ARM ** processor and ARM Interrupt Controller(AINTC) to receive and ** handle interrupts. */ static void SetupInt(void) { #ifdef _TMS320C6X // Initialize the DSP interrupt controller IntDSPINTCInit(); // Enable DSP interrupts globally IntGlobalEnable(); #else /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); /* Enable IRQ in CPSR.*/ IntMasterIRQEnable(); /* Enable the interrupts in GER of AINTC.*/ IntGlobalEnable(); /* Enable the interrupts in HIER of AINTC.*/ IntIRQEnable(); #endif } /* ** This function configures the AINTC to receive the RTC interrupt. */ static void ConfigureIntRTC(void) { #ifdef _TMS320C6X // Register the ISR in the vector table IntRegister(C674X_MASK_INT4, RTCIsr); // Map the system interrupt to the DSP maskable interrupt IntEventMap(C674X_MASK_INT4, SYS_INT_RTC_IRQS); // Enable the DSP maskable interrupt IntEnable(C674X_MASK_INT4); #else /* ** Register the ISR in the Interrupt Vector Table. */ IntRegister(SYS_INT_RTC, RTCIsr); /* Map the RTC system interrupt to channel 2 of AINTC. */ IntChannelSet(SYS_INT_RTC, 2); /* Enable the System Interrupts for AINTC.*/ IntSystemEnable(SYS_INT_RTC); #endif } /* ** This is the Interrupt Service Routine(ISR) for RTC. */ static void RTCIsr(void) { unsigned int timeValue = 0, calendarValue = 0; #ifdef _TMS320C6X IntEventClear(SYS_INT_RTC_IRQS); #else IntSystemStatusClear(SYS_INT_RTC); #endif /* Read the current time from RTC time registers. */ timeValue = RTCTimeGet(SOC_RTC_0_REGS); /* Decode the time in 'timeValue' and display it on console.*/ TimeResolve(timeValue); /* Read the current date from the RTC calendar registers. */ calendarValue = RTCCalendarGet(SOC_RTC_0_REGS); UARTPuts(" ", -2); /* Decode the date in 'calendarValue' and display it on console.*/ CalendarResolve(calendarValue); UARTPuts("\r", -2); } /* ** Delay routine. */ void Delay(volatile unsigned int count) { while(count--); } /****************************** End of file **********************************/ /***************************** End Of File ************************************/
Thank you for your help