Friday, December 7, 2012

Customize ChipKit bootloader into PIC32 Chip


Burn the ChipKit bootloader into a PIC32 Chip
1.      Download the bootloader source file.
2.      Download MPLAB 8 or MPLAB X and the C32 v2.02 compiler
3.      Open one of the bootloader project which is closest to your chip. I have opened uno32.mcp and save it to another project named NewProject
4.      Open the BoardConfig.h and copy one block of code and rename the board name as ‘#elif defined(_BOARD_CHIPKIT_PIC440_)’
a.       Change the capabilities, add blCapUSBInterface
b.      Change the bootLED and download LED pin
c.       Comment # define _USE_UART1_FOR_BOOTLOADER
d.      Define the fLoadFromAVRDudeViaProgramButton pin
                        #define fLoadFromAVRDudeViaProgramButton        (PORTEbits.RE4 == 0)
#define fLoadFromAVRDudeViaVirtualProgramButton (LATEbits.LATE4 == 1)    
#define ClearVirtualProgramButton()             (LATECLR = (1 << 4))
e.       Change the Flash Bytes size : 
#define FLASH_BYTES                 0x80000             // 512K
5.      Open the project in mpLab and programe the code into the chip. Then you need to go into the build options and remove the existing preprocessor macro in the MPLAB PIC32 C Compiler tab and add in the new macro you defined (_BOARD_CHIPKIT_PIC440_).  One important thing is to specify the C32 compiler v2.02.
6.      Program the board in mpIDE with arduino code. If you can blink the LED, you are there.

The detailed process is in ChipKit forum. 
http://www.chipkit.org/forum/viewtopic.php?f=6&t=2134&start=10

Monday, December 3, 2012

Load hex into MPLAB


How can I use my HEX files with MPLAB tools to program my target?


MPLAB is the IDE Microchip provides and provides programming support for all Microchip tools (PICSTART Plus, Promate, ICD2, etc). This provides a simple guide on how to import the HEX file into MPLAB so it can be programmed into your target. For more MPLAB documentation please refer to Microchip's documentation.
First, be sure that your HEX file will run stand-alone (doesn't need a debugger). Click here for pointers on creating a stand-alone HEX file.

Follow these steps:
  1. Start MPLAB. All steps in this FAQ that refer to a toolbar means the toolbar of MPLAB.

  2. Make sure no other project/workspace is open by selecting File -> Close Workspace from the toolbar.

  3. Select your target device by selecting Configure -> Select Device. This will bring-up a dialog where you select your target PIC®MCU(PIC16F877A, PIC18F4520, etc). It also will tell you if your programming tool is supported for this device.

  4. Open the Configuration Bits dialog by selecting Configure -> Configuration Bits from the toolbar. This will open a new dialog window, at the very top of this window you will see a checkbox labeled 'Configuration bits set in code', make sure this checkbox is SET. Failure to do this will cause invalid configuration bits to be written to the device.

  5. Select your programming tool by selecting the Programmer item from the toolbar. This will give you a list of selectable programmers.

  6. Import your HEX file by selecting File -> Import from the toolbar. This will load the HEX file into memory. Importing the hex BEFORE you selected programmer or selected target device will cause the HEX file to be cleared from memory, so it is important to do it in the order shown here.

  7. Program your device. This is done via the Programmer item from the toolbar. This process is different for each programming tool. But for the ICD2, you first need to connect to the device withProgrammer -> Connect Device, and the program the device with Programmer -> Program

  8. Repeat the previous step for each target microcontroller that you wish to program with this HEX file.

Wednesday, November 21, 2012

Illusions of pastoral peace

The quite life of the country has never appealed to me. City born and city bred, I always regarded the country as something you look at through a train window, or something you occasionally visit during the weekend. Most of my friends live in the City, yet they always go into raptures at the mere mention of the country. Though they extol the virtues of the peaceful life, only one of them has ever gone to live in the country and he was back in town within six months. Even he still lives under the illusion that country life is somehow superior to town life. He is forever talking about the friendly people, the clean atmosphere, the closeness to nature and the gentle pace of living. Nothing can be compared, he maintains, with the first cockcrow, the twittering of birds at dawn, the sight of the rising sun glinting on the trees and pastures. This idyllic pastoral scene is only part of the picture. My friend fails to mention the long and friendless winter evening in front of the TV - virtually the only form of entertainment. He says nothing about the poor selection of goods in the shops, or about the unfortunate people who have to travel from the country to the city to get to work. Why people are prepared to tolerate a four-hour journey each day for the privilege of living in the country is beyond me. They could be saved so much misery and expense if they chose to live in the city where they rightly belong.

If you can do without the few pastoral pleasures of the country, you will find the city can provide you with the best that life can offer. You never have to travel miles to see your friend. They invariably live nearby and are always available for an informal chat or an evening's entertainment. Some of my acquaintances in the country come up to two once or twice a year to visit the theater as a special treat. For them this is a major operation which involves considerable planning. As the play draws to its close, they wonder whether they will ever catch that last train home. They city dweller never experiences anxieties of this sort. The latest exhibitions, films, or plays are only a short bus ride away. Shopping, too, is always a pleasure. There is so much variety that you never have to make do with second best. Country people run wild when they go shopping in the city and stagger home loaded with as many of the exotic items as they can carry. Nor is the city without its moments of beauty. There is something comforting about the warm glow shed by advertisements on cold wet winter nights. Few things could be more impressive than the peace that descends on deserted city streets at weekends when the thousands that travel to work every day are tucked away in their home in the country. I has always been a mystery to me why city dwellers, who appreciate all these things, obstinately pretend that they would prefer to live in the country. 



Monday, November 19, 2012

PL2303 schematic



This is the minimum circuit for PL2303. Personally tested

Sunday, November 18, 2012

自控力


想象一下未来的自己
  第一个是希望成为的自己。那个人能坚持锻炼、身体健康、充满能量。第二个是他们害怕成为的自己。那个人懒散度日,毫无活力,体弱多病。这两种想象都能让宅男宅女离开椅子。
  我们还需要记住,为现在的行为承担后果的,看似是未来的自己,实际上还是我们自己。未来的自己会对我们现在的付出感激不尽。

  虚假希望综合征
  我们需要相信,改变是可能做到的。如果失去了希望,我们就会听天由命了。但是,我们必须避免常见的意志力陷阱,即用“改变的承诺”而不是“改变”来改善我们的心情。

  最有效的解压方法包括:
  锻炼或参加体育活动、祈祷或参加宗教活动、阅读、听音乐、与家人朋友相处、按摩、外出散步、冥想或做瑜伽,以及培养有创意的爱好。

  最没效果的缓解压力的方法则包括:
  赌博、购物、抽烟、喝酒、暴饮暴食、玩游戏、上网、花两小时以上看电视或电影。

  有效和无效的策略最主要的区别在于增加大脑中改善情绪的化学物质,如血清素、Y-氨基丁酸和让人感觉良好的催产素。

Thursday, November 15, 2012

Singapore Bird Park


I went to Singapore Bird Park with Chenyang on one Sunday afternoon. The colorful and lively birds impressed me a lot.










Altium netlist to PCB