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_SEG_DOT PORTB.7
#define DISP_SEL_1 PORTA.0
#define DISP_SEL_2 PORTA.1
#define DISP_SEL_3 PORTA.2
#define DISP_SEL_4 PORTA.3
afis:
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:
:020000040000FA
:020000000528D1
:100008000900B0209F200130A100A0015920013033
:10001800F40097200230A1000130A00059200130DF
:10002800F40097200330A1000230A00059200130CD
:10003800F40097200430A1000330A00059200130BB
:10004800F40097200130A1000430A00059200130AD
:10005800F40097200230A1000530A000592001309B
:10006800F40097200330A1000630A0005920013089
:10007800F40097200430A1000730A0005920013077
:10008800F40097200130A1000830A0005920013069
:10009800F40097200230A1000930A0005920013057
:1000A800F4009720072863005828200AA300C220DC
:1000B800A200061086100611861106128612061373
:1000C80086130510851005118511210303190514E0
:1000D8000230210203198514033021020319051582
:1000E800043021020319851522180614A218861453
:1000F80022190615A2198615221A0616A21A86169C
:10010800221B0617A21B86170800F30AC030F1004D
:100118000330F000F00B8E28F10B8C28F20B8A28A4
:10012800F30B8A280800E830F2000330F300892036
:10013800F40B97280800831603130610861006117F
:1001480086110612861206138613051085100511EE
:1001580085118312031308001F10831603139F13BE
:100168009F111F159F141F1007309C008312031343
:100178008501860187018801890108000B30230267
:10018800031800342308013E0310D03EA3000030BA
:100198000318013E8A00230882000A343F340634DB
:1001A8005B344F3466346D347D3407347F346F34B8
:02400E007A3FF7
:00000001FF
Un comentariu:
If you just keep trying you will success, thats what I always believe.
Trimiteți un comentariu