![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
hello there
i am new to micro controllers specially the PIC's i am so glad that a couple of seconds ago i foud out the MR Nigel Goodwin is one of moderators at here because my questions are about a pic programmer that i built some of days ago from this web site: http://chaokhun.kmitl.ac.th/~kswichit/f84/f84.htm and the pic software is writen by MR Nigel. anyway the pic programmer is good and i made it with no problem now my biggest problem is that i am not familiar with the software and C language i want to start with a ready circuit and a given code but i have the following problems: 1: what is the difference between HEX files and source codes? my mean is what i must do with them in the Nigel software? i dont know i must use from bothe hex and source or one of them or each one...? the source codes are based "C" language and i thought i should use from them with the nigel software but dont know what are the hex files so? 2: before writing to the pic micro what i must do at first? Erasing, reading or...? 3:such as i know there is a button or any else thing the cause that the micro be burned after writing and after this we can not read or write into micro, so what is this button or... for the pic with Nigel software? i think thats's enough for now, and i hope i could programming my 16f84 pic with your guides and helps thanks for any input and really sory if my questions are stupid. |
|
|
|
|
|
|
(permalink) | ||||
|
Quote:
Quote:
Quote:
Quote:
|
|||||
|
|
|
|
|
(permalink) |
|
ohh hello Nigel
thanks for the reply such as i found out from your post so i can use from EACH source code or hex code depending on each one i have and if i use from source code in your software it would be converted to hex file by the software, and if i have the hex file i write it to your software and it would exchange to machine code. is this correct? if so then the software do all thing wether i input the source code OR hex code? i hope i could understand your mean correctly but what did you mean with this? "You write the source code, assemble or compile it to a HEX file, then load the HEX file into my programmer software and load it into the PIC." if i have a source cod i shoud put it in your software DIRECTLY or....? can you please answer my "2" question i aske at my first post? how i can burn the pics? my mean is i write into them and then protect them from reading and writing? thanks |
|
|
|
|
|
|
(permalink) |
|
here's a hex file and a source code from A circuit with 16f84
:1000000000308A00AE2800000000F73065000030A4 :10001000051901300038031D0F2811141116D228BC :100020008E0A3C300E02031C21288E018F0A3C30C0 :100030000F02031C21288F01900A183010020318A8 :100040009001D82814088900831608148312080820 :1000500095000A301502031C3328203015020318BE :100060003328063095021A301502031C39280C304B :1000700095020130140797001708890083160814A9 :100080008312080896000A301602031C4D282030FF :10009000160203184D28063096021A301602031C69 :1000A00053280C30960200341108403900380319E7 :1000B0007C28940114088900831608148312080808 :1000C0008C000C0A03197C28222015081002031D3D :1000D000792816080F02031D7928023014079700AB :1000E000170889008316081483120808FF3A03389A :1000F0008600033094075A28D92817308400000856 :1001000003198A2888280000000000000000000071 :10011000800B83289628930A12081302031D9A283D :10012000003066000610643097007D2800306600BD :1001300006149301DA281108013900380319AD2893 :100140003E30940022201508900016088F008E0182 :1001500011179112111003309200DB2884018301E2 :1001600004308C008C1DBC28073081018130840054 :100170000008C0390F388000640081308400000816 :10018000C0390C0480000030660006109101013077 :10019000920093018101123090008F018E010B19A2 :1001A000D3280528CF280B110030660086171028A9 :1001B00054288B289B28003066008613CF286300C4 :02400E00F83F79 :00000001FF ;PIC16F84 F84 Miniature Realtime Controller V1.0 // PIC16F84 LP Xtal 32768Hz runs rtc.c // The RTC.C was compiled by PCW PIC C Compiler V2.266 // April 10,1999 // Copyright(C) 1999 Wichit Sirichote #include <RTC.H> #fuses LP,NOPROTECT,NOWDT // must include this line !! // set clock to 19:00 when press set time button once // change below for your convenient #define setHour 19 #define setMin 0 // Scheduler format in eeprom /* address data 2100 19 00 04 19 01 00 FF FF as seen in Nigel's data memory 2108 FF FF FF FF FF FF FF FF window ........... meaning 2100 19 ; set hour 2101 00 ; set min 2102 04 ; output byte to be sent to port_B, '1' turn on, '0' off .... FF byte is end of stored PGM output byte use '1' means turn the device on RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 OUTPUT NC 5 4 3 2 1 NC NC NOTE! output byte seen in Nigel's EEPROM window must be HEXadecimal, e.g. Suppose at 20:00 turn output 1 and 2 on, the output byte must be 0 0 0 0 1 1 0 0 = 0C */ // rename i/o devices #define LED PIN_B0 #define KEY PIN_A2 // variables declaration char sec,min,hour,flag1,rate,temp,i,A,B; // Bit assignment of flag1 // mask byte effect // 0x20 installation test on/off(0) // 0x40 compare time enable bit(1) // 0x10 blink disable (1) // 0x01 button pressed (1) time() // update clock every 1 second { sec++; if ( sec >= 60) { sec = 0; min++; if ( min >= 60) { min = 0; hour++; if ( hour >= 24) hour = 0; } } } // convert() function provides direct entering decimal value of preset // time in 64 bytes eeprom data memory // say, 19 00 04 ; when reach 19:00 turns RB2 on // as seen by Nigel's PigPro16 eeprom window, 19 means 19h or 25d // convert will substract 25 with 6 giving 19. // similarly but substract with 12 if > 19, e.g., 20h or 32d convert // function will give 32d - 12d = 20. convert() // entry : index pointer i // exit: A,B { A = read_eeprom(i); if ((A > 0x09) && (A < 0x20)) A = A - 6; // convert 10h-19h to 10d-19d if ( A> 0x19 ) A = A - 12; // convert 20h-23h to 20d-23d B = read_eeprom(i+1); if ((B > 0x09) && (B < 0x20)) B = B - 6; if ( B > 0x19) B= B - 12; } scan_PGM() // scan program saved in user eeprom { if((flag1 & 0x40) != 0) // allow entering only after S1 has been pressed { i = 0; while( read_eeprom(i) != 0xff) // if not EOF (0xff) do { convert(); if (hour == A && min == B) port_B = ~read_eeprom(i+2)|0x03; // fire output i = i+3; // next address } } } setTime() { if ((flag1 & 0x01) != 0) //input(KEY)==0) { hour = setHour; min = setMin; sec = 0; flag1 |= 0x40; // enable compare time flag1 &= ~0x20; // reenable test on off flag1 &= ~0x01; // clear key press bit rate = 3; } } blink() // turn LED on 100 ms { output_low(LED); delay_ms(100); output_high(LED); } fireLED() { temp++; if ( temp == rate) { blink(); temp = 0; } } chkKEY() { if(input(KEY)==0) {flag1 |= 0x01; // set bit 0 telling key been pressed flag1 |= 0x10; // disable firing LED // output_high(LAMP); // turn on lamp when press button } } main() { setup_counters(RTCC_INTERNAL,RTCC_DIV_32); // [32768/4]/32 = 256Hz /* 256Hz clock will be counted by Timer, when it rolls from FF to 00 T0IF will then be set, in other word, one second has elapsed */ output_low(LED); flag1 = 0; rate = 1; temp = 0; tmr0 = 0; hour = 18; min = 0; sec = 0; while(1) { while(!bit_test(intcon,2)) chkKEY(); // check key S1 while T0IF = 0 bit_clear(intcon,2); // the following tasks executed every 1 second output_high(PIN_B7); // use RB7 for measuring tasks execution time(); scan_PGM(); fireLED(); setTime(); output_low(PIN_B7); } } |
|
|
|
|
|
|
(permalink) | |||
|
Quote:
Quote:
Quote:
There's no write protection on a PIC (nor any need for it!). |
||||
|
|
|
|
|
(permalink) |
|
When you enable the code protect does it just prevent the PIC from being read? I have not tried that feature yet.
__________________
I was born with nothing. And I still have most of it! |
|
|
|
|
|
|
(permalink) | |
|
Quote:
If you DO use code protection, makes ABSOLUTELY SURE you have multiple copies (in different locations) of both your source code and HEX file - because you won't be able to recover the code from the PIC if you should lose your original code!. |
||
|
|
|
|
|
(permalink) |
|
hi
ok thanks Nigel so why your software has a part called " source code"? i had some of problems when i put the above HEX files in your software while writing and has these errors while writing: "program Verify failed on line 0, program aborted" or "program Verify failed on line 8, program aborted" i dont know wht is the problem really? please i need for more help to write in my pic how i can find out that my pic is the programed aftter programing? if i read the pic micro with "READ PIC" after programing it what will happen? what i will have aftter reading the pic? my before writings or...? i am so sorry for my stupid questions but i need more and more help to go ahead |
|
|
|
|
|
|
(permalink) | |||
|
Quote:
Quote:
Quote:
|
||||
|
|
|
|
|
(permalink) | ||||
|
Quote:
Quote:
Quote:
Quote:
|
|||||
|
|
|
|
|
(permalink) |
|
ok i went to software option part and turned Vpp and VDD
on and measured the voltage on the MCLR and on the VDD voltage on the MCLR =13.4V voltage on the VDD = 4.9V i used from a 18V transformer for the circuit(hardware) i dont know what is the problem that i can not write to my pic and when i read it, it seems that my pic is empety. this means my codes never went in the pic!!? :cry: such as you say Nigel , the software can generate source codes from hex file but cannot do the opposit way? i dont know what is the problem, when i exchange $3BC port to $378 it comeback to $3BC port again!? |
|
|
|
|
|
|
(permalink) | ||||
|
Quote:
Quote:
Quote:
Quote:
|
|||||
|
|
|
|
|
(permalink) |
|
no i used from an AC 18V transformer with a full wave rectifier diode like the schematic
i think that two 87Lxx and capacitors connected to these ICs makes the ripples very limited from where i can download MPASM or MPLAB? if i have a "C" code what software i need for? Nigel, i put that HEX file you see above at 4 post in a text document and opened it to the software and have no problem with this but when i push the Write pic button i get this error "program Verify failed on line 0, program aborted" please see the hex program, perhaps the problem is from the hex file? |
|
|
|
|
|
|
(permalink) | ||||
|
Quote:
Quote:
Quote:
Quote:
I presume you have WinPicProg configured correctly for the programmer you're using?. |
|||||
|
|
|
|
|
(permalink) |
|
i cheked the hardware again and it seems there is no problem with it
i dont know what is the problem and i am so confused now the only thing that i think about is: perhaps the problem is from the cable because my caple that goes to printer port has some of wires conected to ground and i assume that there are the problem but i am not sure if i must cut them or not :cry: Nigel, does your software works with all kind DIY pic programmer? i want to built another kind, perhaps such as this:http://www.jdm.homepage.dk/newpics.htm http://www.jdm.homepage.dk/easypic.htm |
|
|
|
|