Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

hallo friends! i am new to embedded programming..i have a task kindly help me out.

Status
Not open for further replies.

akiras23

Newbie level 3
Joined
Oct 21, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
66
Task 1

The I/O pins of the main controller situated on the daughter board are multiplexed (they can be used
for multiple functions). Hence the aim of the first subtask is to configure these pins as General
purpose input output for LEDs. Therefore it is necessary to refer the additional document
(“additional.pdf”) provided and find the corresponding “PCR” register associated with the LEDs. The
first page of the additional document shows the mapping of peripherals onto different pins of the
controller. The correct pins/port for the LEDs (D0-D7) with the corresponding “PCR” register number
can be found in the additional document. The below table (table 2.2.1) shows IO port pin mapping.
As an example port pin PA9 corresponds to LED D0, and the PCR register number for this LED from
the additional document is 9.
LEDs can be configured as output by writing “0x0200” to the corresponding “PCR” register.
The function “configure_io()” shall be used for this task.
In order to glow a LED, a low signal (“0”) should be driven on the I/O pin. And for turning off a high
signal(“1”) should be driven on the I/O pin.
Example for LED glow – “SIU.GPDO[X].R = 0;” where X stands for the corresponding PCR register. ASE Practical: Experiment 1
9

Table 2.2.1



2.3. Task 2

The light sensor (photoconductive cell) is used in automobiles to automatically turn on/off the head
lights. The implementation of this exercise shows the automatic activation of actuators regarding
sensor data. This example of automatic head lights is similar to the automatic windshield wiper.


Subtask 1:
The ADC converted value given by the light sensor is being stored the in the Register
“ADC_0.CDR[2].B.CDATA”.
This subtask concerns with displaying the value of the light sensor data through LEDs.
The controller pin has to be configured for analog input, which can be done by writing “0x2500” to
the corresponding PCR register. Please refer to table 2.2.1 for the corresponding port/pin. The light
sensor has been connected to the ANA IN1 input feature. The code for the analog pin configuration
should be entered in the “configure_io()” function.

The function “showdata(value)” contains the code for the different value levels. The task is to glow
LEDs corresponding to each level i.e. for the highest value of the sensor all the LEDs should glow.
Please check and modify the function “showdata(value)” in the provided code.

Subtask2:
This subtask concerns with the usage of the potentiometer provided on board. The converted value
from the potentiometer is being stored in the register “ADC_0.CDR[4].B.CDATA”. Use this data
register instead of light sensor data register with the same function (“showdata(value)”).
Please note that for getting the converted values in the ADC data register, the corresponding
controller pin has to be configured in the same manner as the light sensor, the corresponding PCR
register is not the same in this case.


Subtask 3:
The digitally converted values of the ADC unit lie between 0 – 1024 (10bits).
Use the data from the light sensor and invert the behavior of the function and change the function
“showdata(value)” so that 5 levels of light intensity are indicated, utilizing LED D4. Hence for
minimum light, LEDs D0 to D4 should glow and for maximum light, no LEDs should glow. ASE Practical: Experiment 1
11

2.4. Task 3

The PIT (Periodic Interrupt Timer) module on the board provides 4 different timer channels for usage.
The task is related to the configuration of buttons and usage of timers.
Subtask 1:
Similar to the LEDs, the buttons and switches “BT5”, “BT6”, “SW1” etc. are also mapped to each pin
of the controller. The correct “PCR” register can be found by following the same procedure as LED
configuration.
A button can be configured as input by writing “0x0100” to the corresponding PCR register.
A button press or a switch on action gives a low signal (“0”) on the pin. This signal can be checked by
the input register of the corresponding pin (“SIU.GPDI[X].R”, where X= corresponding PCR register
number).
The button/switch action should be indicated by a LED glow.

Subtask 2:
The PIT timer channels 0 and 1 have already been configured. The timers can be started by calling the
Function “conf_timer0(int mode, int value)” . The description of the parameters can be found in the
below provided table.

Parameter Description
Mode 0 – Turn off the timer channel
1 – Turn on the timer channel
Value Timer period in milliseconds. (1 sec = 1000ms)

The timer should be configured with a valid mode and a valid time. The configured period causes
interrupt timer. At every periodic interrupt the function “timer0_intr” is being called. To indicate the
timer working, LED D0 shall blink at every timer interrupt. “SIU.GPDO[X].R = ~SIU.GPDO[X].R” (where
X = PCR register number) can be used to for blinking.
Notice the implementation is an endless loop. The timer channel should be switched on/off using
SW1, if the switch state is changed. Implement the described functionality.
This exercise shows a part of the indicator control of an automobile. In a later practical the indicator
control will be expanded of the possibilities of left, right and hazard flashing.

ASE Practical: Experiment 1
12
2.5. Additional Task 4

Read the document PIT.pdf and write the code for configuration in the function conf_timer1().
Implement the same functionality as task 3 - subtask 2 using timer channel 1. The periodic interrupt
by this timer causes the function call “timer1_intr()”.
Please note: The system clock frequency needed for the counter countdown for this task is 16MHz.


Code:
#include "api.h"

void showdata(int value);
#pragma inline showdata



void configure_io(void)
{
//Task1
//Please enter the PCR register numbers and initialitation code here 
// LEDs 

   // SIU.PCR[].R = ;       // D0
   // SIU.PCR[].R = ;      // D1
   // SIU.PCR[].R = ;      // D2
   // SIU.PCR[].R = ;      // D3
   // SIU.PCR[].R = ;      // D4
   // SIU.PCR[].R = ;      // D5
   // SIU.PCR[].R = ;      // D6
   // SIU.PCR[].R = ;      // D7 

//task 3
// Buttons & switches
    //SIU.PCR[].R = ; //BT5
    //SIU.PCR[].R = ; //SW1

//task 2 
// Analog inputs configuration
  //SIU.PCR[].R = ;
  //SIU.PCR[].R = ;
    
}



void main(void)
{
    int value;
    

    init(); // board initialization
    
  
    
    
   for(;;) // inifinite loop
   {
   //task 1 - please enter your code for checking LEDs here
   
   // task 3/ task 4 - code for checking button press and timer enable/disable goes here 
   
   
   //task2
   //value = ;
   //showdata(value);
  
   
   
      
   } // End for loop
    
} // End main




void showdata(int value) // task2
{
        if(value <= 256)
        {
        
            // task 2 
            // LED status to be shown 
            // D0 - on, D1 - off, D2 - off D3 - off
        }
        else if(value > 256 && value <= 512)
        {
        
            // task 2 
            // LED status to be shown 
            // D0 - on, D1 - on, D2 - off D3 - off
        }
        else if(value > 512 && value <= 768)
        {
        
    
            // task 2 
            // LED status to be shown 
            // D0 - on, D1 - on, D2 - on D3 - off
        }    
        else
        {
        
  
            // task 2 
            // LED status to be shown 
            // D0 - on, D1 - on, D2 - on, D3 - on
            
        }     

}
void conf_timer1(void)
{
// Task 4 
// Timer channel Channel 1

    //PIT.CH[1].LDVAL.B.TSV = ; //Time Start Value Bits     
    //PIT.CH[1].TCTRL.B.TIE = ; // Timer interrupt Enable
    //PIT.CH[1].TCTRL.B.TEN = ; // Timer enable 
    //PIT.CH[1].TFLG.B.TIF = ; // Clear Timer Flag 
}

void timer0_intr(void)
{
// task 3 subtask 2 - LED blink code goes here

        
}
void timer1_intr(void)
{
// task 4 - timer 1 interrupt function 

}
 
Last edited by a moderator:

bro i have only additional.pdf
 

Attachments

  • additional.pdf
    209 KB · Views: 100

bro how can i solve this code? any idea?
 

bro once check this files
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top