Wednesday, 15 June 2016

Run Pinned Shortcut in Taskbar as Administrator in Windows

Luckily you can set Run as administrator option from the shortcut in this case.
  1. Right-click the shortcut in your task bar.
  2. Right-click the program's name (say Command prompt for instance)
  3. Click on Properties.
  4. Click the Shortcut tab.
  5. Click the Advanced... ...
  6. Check the Run as administrator check box.
  7. Click the OK button.

Monday, 6 July 2015

[MCU] Microcontroller Packaging

QFN : Quad Flat No Leads:

These connect IC's to PCB's without through-holes.
The figure shows with lead frame and wire bonding. Flat no-lead packages include an exposed thermal pad to improve heat transfer out of the IC (into the PCB).  Hand soldering is not possible with this package




QFP: Quad Flat Package

A surface mounted IC, pins extending for all the 4 sides.  Socketing such packages is rare and through-hole mounting is not possible.




LQFP: Low Profile Quad Flat Package (1.4mm)



TQFP: Thin Quad Flat Package (1.0 mm) 

Has shorter leads than the LQFP. To be used in a space constrained designs.
Helps in solving increased board density.

References

https://en.wikipedia.org/wiki/Quad_Flat_No-leads_package
https://en.wikipedia.org/wiki/Quad_Flat_Package


Friday, 12 June 2015

[Exploring Freescale MCU Programming] #5 RTC (Real time clock) set and Time and alarm

#2 -  next one in my pipeline is Realtime Clock (RTC) initialize and get it working.

What is RTC?


real-time clock (RTC) is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time. Although the term often refers to the devices in personal computers,servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time.

RTC in K20D Freescale Board


The Real Time Clock (RTC) module on the K20 has two modes of operation, system power‐up and system power‐ down. In system power‐up mode, the RTC may be powered by either the MCU regulator or the backup power supply, VBAT. During system power‐down, the RTC is only powered from the backup power supply, VBAT


I have used RTC with a FRDM-K20D50 Board to schedule an alarm at regular intervals.



The CPU Settings should enable the RTC Oscillator. Otherwise RTC will not work.




RTC Component added.



Setting Properties for the RTC Component



Now lets add the code to set the RTC time and get it back, the main.c


Code to set and get time

printf("--Test init--\n");
LDD_RTC_TTime ttime;
ttime.Day = 11;
ttime.Month = 06;
ttime.Year = 2015;
ttime.Hour = 17;
ttime.Minute = 45;
ttime.Second = 15;

RTC1_SetTime(NULL, &ttime);


int i;
for(i=1;i<=3000000;i++)
{

}

LDD_RTC_TTime ttime1;
RTC1_GetTime(NULL, &ttime1);

printf("%d-%d-%d %d:%d:%d\n", ttime1.Day, ttime1.Month, ttime1.Year, ttime1.Hour, ttime1.Minute, ttime1.Second);



Output

--Test init--
11-6-2015 17:45:16


- Printed the RTC time that is set

Lets try setting RTC alarm and triggering it

Enable the methods setAlarm and enable onAlarm Event and generate code



main.c

ttime1.Second += 30;

RTC1_SetAlarm(NULL, &ttime);

Event.c

void RTC1_OnAlarm(LDD_TUserData *UserDataPtr)
{
printf("---Alarm Triggered--\n");
LDD_RTC_TTime ttime1;
RTC1_GetTime(NULL, &ttime1);

printf("%d-%d-%d %d:%d:%d\n", ttime1.Day, ttime1.Month, ttime1.Year,
ttime1.Hour, ttime1.Minute, ttime1.Second);

}


Output after alarm


---Alarm Triggered--
11-6-2015 17:45:26


Project:


Wednesday, 20 May 2015

[Codewarrior 10.6 Solution] printf(%f) Does not work

printf("-Value %f\n", floatValue) -   prints -Value %f as such, instead of the float value in the console.

Solution :  Change a project settings

Project   ->   Properties  ->  C/C++  Build  ->  Settings  ->  Tool Settings Tab ->  Librarian  -> 

Change print formats  to int_FP



Thursday, 30 April 2015

[Freescale K20D50M MCU Programming] #4 External LED controlled by a GPIO Switch

#4 External LED  controlled by a GPIO Switch

We tried blinking of an LED. Now we will create a switch using one of the GPIO Pins.  The Reset Button in FRDM-K20D50 does not have an alternate function. Hence I wanted to try out a Input switch.

Take a look at the [Freescale K20D50M MCU Programming] #1 Helloworld on the Console using Processor Expert  for quickstart 

Lets get started.


First we need 2 things. 


  • Identify the PIN for the external LED and a ground pin
  • then another PIN to act as a Switch Input and a ground pin

I identified PTC0  and PTB2 respectively.






to see the schematic to identify the PINS.  There is a good youtube video which gives an example on K25Z board.


Next we will be adding the BITIO_LDD for the LDD configured to the PTC0 PIN.




Then a BITIO_LDD for the switch on PTB2



Setting up the BITIO_LDD isn't enough for the acting with in PTB2.  We need to initialize the GPIO for the PIN. We will add a init_GPIO component and configure it to PTB




Generate the Pex code, and then add then lets add the below logic to toggle the led based on whether a wire between PTB2 and the GRND is connected or not..


The Pin's are connected to cathode, so 0 means high and 1 means low.

Code in main.c 

  for(;;)
  {
  if(SW1_GetVal(NULL)==0)   // CONNECTED 
  {
  led_SetVal(led_DeviceData);
  }
  else
  {
  led_ClrVal(led_DeviceData);
  }
  WAIT1_Waitms(1000);
  }


Now build the code and lets test it. 

Here is how the pins are connected on the board




Now lets see what happens with ehe pins at PTB0 is connected, the red wires on the top side is connected.. and you see the LED glowing


Now lets see what happens when one of the wire on top is pulled out..

Do you see only 1 wire on top is connected, and the LED is off.

This is an example of how you use a GPIO pin as a switch to control through software.



Wednesday, 22 April 2015

[Freescale K20D50M MCU Programming] #3 Blinky GPIO - External LED

#3  Blinky External LED 


In [Freescale K20D50M MCU Programming]  #2 Blinky Red LED  onboard, We tried blinky with onboard LED. Lets try out blinking the external LED connected to a GPIO pin.. We are going to use Codewarrior and processorexpert with FRDM-K20D50M board

Take a look at the [Freescale K20D50M MCU Programming] #1 Helloworld on the Console using Processor Expert  for quickstart  

Lets get started.

First we need to see the schematic to identify the GPIO pin for our external LED.  There is a good youtube video which gives an example on K25Z board.






and the pin connectivity as below





Now Lets create a new project as mentioned in [Freescale K20D50M MCU Programming]  #2 Blinky Red LED  onboard we add a BITIO_LDD Component







And setting the properties to PTD0




I have added a WAIT custom component from processor expert to show a delay


And add this code in main.c

  gpio_led_NegVal(NULL);
  WAIT1_Waitms(1000);

  gpio_led_NegVal(NULL);

And you see the external LED Blinking.




video

Wednesday, 15 April 2015

[Freescale K20D50M MCU Programming] #2 Blinky Red LED onboard

#2  Blinky Red LED onboard


Lets try out blinking the RED onboard LED. We are going to use Codewarrior and processorexpert with FRDM-K20D50M board

Take a look at the [Freescale K20D50M MCU Programming] #1 Helloworld on the Console using Processor Expert  for quickstart 

Lets get started.


First we need to see the schematic to identify the onboard LED.  There is a good youtube video which gives an example on K25Z board.




LED  Schematic :





Red LED connected to D6.
Green LED connected to D3
Blue LED connected to D9



Identify the Ports and Pins for the LED's :



Red, look for D6





Green, Look for D3



Blue, Look for D9








The FRDM-K20D50 CPU uses the Blue LED. So, this has to be disabled to get this on-board LED to work.




Then Lets add BITIO_LDD component, 1 for each LED to control them.

Now lets setup the Bit_IO pins for the 3 LED's.  LED Cathode is connected to the microcontroller pin. i.e., Low Level (0) turns it on, and (1) turns it off.   By default we need to set all the 3 LED's to (1) to turn it off.


WE add 3 BitIO_LDD Components, for RED, Green and Blue. 




Green LED -> Switch off by Default. Cathode connected. So 1 is Off


Blue LED -> Switch off by Default. Cathode connected. So 1 is Off. But this pin is used by CPU, so enable PIN Sharing.




Red LED -> Switch ON by Default. Cathode connected. So 0 is On.



Now build and Run the Main.c  you will see the RED LED glowing by the code is flashed.







Now lets make a blinky. :-)


We need to enable the NegVal() method of the BitIO_LDD






And add this code in the main.c or processorexpert.c

int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  for(;;)
  {
 int i =0;
 for(i=0;i<=1000000;i++)
 {
 }
 RED_LED_NegVal(NULL);  // Blink the RED Led
  }
  

Here is the blinky.


video

CodeWarrior, PEX Project :   Download  onboard_blinky.zip