18 decembrie 2011


In these days seems that you cannot light a simple LED without a very complicated electronic hardware (microcontroller with some Quartz Crystal around it etc).
So, I started to become interested in these "chips" becuse I do not want to be so "obsolete"...
First, I started by searching a development board...
I soon received from a fellow ham a EasyPIC 2 Development Board fitted with everything you want.
After that, I stated to search for a suitable PIC to start with. A 16F877A seems to be the best for a beginner because has A/D converters and a lot of I/O ports.
The interest in PIC was determined by the need for some repeater automation, including battery management.
After a lot of struggling, I manage to read and write the PIC using the onboard USB programmer. This was by far the most time consuming phase (a few weekes of study). Don't laugh! I have no one to help me but some internet related posts!
To make the long short, after a successfull R/W operation, I manage to blink a LED but this don't count as a "Hellor World" project because was made with a downloaded .hex file!
I read (and trying to understand) various things about uC.
I soon found that I need a Programming tool and a compiler.
Everyone pointed me to MikroE solutions: MikroBasic and MikroC. Also I read Mr's Surducan book about microcontrollers and JAL (Just Another Language) as reccomended by some uC specialist.
After a lot of reading (and sometime "lot-of-no-understandings") I stayed on BASIC.
This is my first, true, "Hello World" project:

;Chip Settings
#chip 16F877A,10
#config OSC=HS

;Defines (Constants)
#define DISP_COUNT 4
#define DISP_SEG_A PORTB.0
#define DISP_SEG_B PORTB.1
#define DISP_SEG_C PORTB.2
#define DISP_SEG_D PORTB.3
#define DISP_SEG_E PORTB.4
#define DISP_SEG_F PORTB.5
#define DISP_SEG_G PORTB.6
#define DISP_SEL_1 PORTA.0
#define DISP_SEL_2 PORTA.1
#define DISP_SEL_3 PORTA.2
#define DISP_SEL_4 PORTA.3

DisplayValue 1, 0
Wait 1 s
DisplayValue 2, 1
Wait 1 s
DisplayValue 3, 2
Wait 1 s
DisplayValue 4, 3
Wait 1 s
DisplayValue 1, 4
Wait 1 s
DisplayValue 2, 5
Wait 1 s
DisplayValue 3, 6
Wait 1 s
DisplayValue 4, 7
Wait 1 s
DisplayValue 1, 8
Wait 1 s
DisplayValue 2, 9
Wait 1 s
Goto afis

This program is intended to be used with a 16F877A Microchip PIC,
a 10 MHz crystal and a 4 digit, 7 segment LED display.
It count from 0 to 9 but the number is displayd alternatively from left to right.
As I cannot attach the .hex file, use Copy/Paste and a txt editor to make your own hex file
to upload into the uC:


Un comentariu:

Shahana spunea...

If you just keep trying you will success, thats what I always believe.

Postări populare

OnLine logbook YO3HJV