View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
Help compiling for a 16f628A |
Posted: Sun May 16, 2004 7:29 pm |
|
|
I recently wrote a small piece of code for the pic16f628 but accidently ordered 628A's. I have an old version of the compiler that does not work for the A's. Can someone please do me a favor and compile this code for me? Thanks,
Ringo
[email protected]
#include <16F628A.h>
#use delay(clock=20000000)
#fuses HS,NOWDT
//#use rs232(baud=9600,bits=8,parity=N,invert,xmit=PIN_A0)
#use rs232(baud=9600,bits=8,parity=N,xmit=PIN_A0)
#define Relay1_pin PIN_A1
#define Relay2_pin PIN_A2
#define Relay3_pin PIN_A3
#define Relay4_pin PIN_A4
#define Spare2 PIN_A5
#define Spare3 PIN_B0
#define Spare4 PIN_B1
#define Spare5 PIN_B2
#define Spare6 PIN_B3
#define Spare7 PIN_B4
#define Spare8 PIN_B5
#define Spare9 PIN_B6
#define Spare10 PIN_B7
int SERIAL_BUFFER[8]; // communications buffer
int Packet_Length;
int i;
void init_pic();
void main()
{
init_pic();
output_low(PIN_B3);
delay_ms(500);// delay 1 sec for everybody to wake up
//printf("Test Message #%d just to see how it works.\r\n",i);
/*printf("MA0\r\n");
printf("MB0\r\n");
printf("MC0\r\n");
printf("MD0\r\n");
printf("CPA00000000\r\n");
printf("CPB00000000\r\n");
printf("CPC00000000\r\n");
printf("CPD00000000\r\n");
*/
printf("MA0\r");
printf("MB0\r");
printf("MC0\r");
printf("MD0\r");
printf("CPA00000000\r");
printf("CPB00000000\r");
printf("CPC00000000\r");
printf("CPD00000000\r");
Delay_ms(500);
output_high(PIN_B3);
While(1)
{
// sit here and spin
}
}
void init_pic()
{
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_vref(FALSE);
setup_comparator(FALSE);
output_low(Spare2);
output_low(Spare3);
output_low(Spare4);
output_low(Spare5);
output_low(Spare6);
output_low(Spare7);
output_low(Spare8);
output_low(Spare9);
output_low(Spare10);
}
_________________ Ringo Davis |
|
|
hillcraft
Joined: 22 Sep 2003 Posts: 101 Location: Cape Town (South africa)
|
Here you go |
Posted: Mon May 17, 2004 9:30 am |
|
|
:1000000000308A00AB2800000A108A100A1182070B
:100010004D34413430340D3400340A108A100A1142
:1000200082074D34423430340D3400340A108A10C3
:100030000A1182074D34433430340D3400340A1031
:100040008A100A1182074D34443430340D340034A0
:10005000F701F71D33280730810181308400000843
:10006000C0390F3880006400813084000008C03936
:100070007704800090010030F80092000030831671
:1000800092009F0183129F018316050800398500A5
:100090001030F700F70B4A28000083121F080C13DA
:1000A000831685128312851283160610831206109A
:1000B000831686108312861083160611831206118A
:1000C0008316861183128611831606128312061276
:1000D0008316861283128612831606138312061362
:1000E0008316861383128613B5282B3084000008EC
:1000F000031987280630F800F701F70B7D28F80B65
:100100007C287B30F700F70B8328800B7A2800349B
:1001100083160510831205100830F8000000000057
:100120000000F817A228F813AB0C03180514031CE1
:1001300005107817A2287813F80B94280000000007
:1001400000000514A7308400840BA428F81B932812
:10015000781B9B28003484011F30830507309F00E3
:10016000831605108312051428288316861183121E
:1001700086110230AA00FA30AB007520AA0BBB280A
:10018000AA012A080420AA0AF700AB00882004303C
:100190002A02031DC128AA012A080D20AA0AF70075
:1001A000AB00882004302A02031DCC28AA012A08AB
:1001B0001620AA0AF700AB00882004302A02031D8B
:1001C000D728AA012A081F20AA0AF700AB00882016
:1001D00004302A02031DE2284330AB00882050304F
:1001E000AB0088204130AB0088200830AA003030B6
:1001F000AB008820AA0BF7280D30AB0088204330D5
:10020000AB0088205030AB0088204230AB00882003
:100210000830AA003030AB008820AA0B0A290D3024
:10022000AB0088204330AB0088205030AB008820E2
:100230004330AB0088200830AA003030AB00882063
:10024000AA0B1D290D30AB0088204330AB0088205D
:100250005030AB0088204430AB0088200830AA0022
:100260003030AB008820AA0B30290D30AB0088203D
:100270000230AA00FA30AB007520AA0B3A29831687
:0A02800086118312861543296300DE
:02400E00EA3F87
:00000001FF
;PIC16F628A
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 17, 2004 12:31 pm |
|
|
Quote: | setup_comparator(FALSE); |
Be aware that this line may not produce the desired result,
based on the compiler version.
This is because FALSE is defined as 0, but in a modern
version of the compiler, FALSE is not a valid argument
for the setup_comparator() function. You have to use
NC_NC_NC_NC as an argument. For PCM vs. 3.188
it's defined like this:
#define NC_NC_NC_NC 0x0ff07
But in a slightly earlier version, it had a different
definition, as I recall.
---------------------------
What is your version of the compiler ?
There may be a better way for you to use it for the 16F628A.
If I know your compiler version, I can check on it. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
Comiler version |
Posted: Mon May 17, 2004 4:13 pm |
|
|
I have 3.050. The setup_comparator(FALSE); line was inserted by the pic wizard, so I hope it works. Would you mind taking it out and compiling it for me and sending it to me via email?
Thanks
Ringo _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 17, 2004 5:54 pm |
|
|
Quote: | Would you mind taking it out and compiling it for me and sending it to
me via email? |
There's no point in having people compile the code for you, because
you'll need to revise it as you discover bugs.
For example, are you using Low Voltage programming mode ?
If not, you need to put NOLVP at the end of your #fuses statement.
I used PCM vs. 3.188 and compiled your file for both the 16F628
and the 16F628A. I then compared the two hex files. The only
difference is the name of the PIC that CCS puts on the end of the file.
(I changed the setup_comparators() line to use NC_NC_NC_NC as
the parameter before compiling).
So the modern compiler (vs. 3.188) doesn't treat the two PICs
differently. The hex file code is the same for both.
So if your version of the compiler works for the 16F628, it should
mostly work for the "A" version. If you look in the back of the
data sheet for the 16F628A, it has "APPENDIX C: DEVICE MIGRATIONS".
This section tells the differences between the "A" and the "non-A"
versions of the PIC. Most of the changes have to do with the Config bits
(#fuses) for Code Protect, or various oscillator modes. But you're not
using those modes. So I don't think it's a problem. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
differences |
Posted: Mon May 17, 2004 6:34 pm |
|
|
Thanks for the info on the compiled versions, that�s what I needed to know. I'll just compile it for the 628 and then edit it and add the A just for completeness. As for revising the code I think it is done. It's a very simple project that just needs to send a serial string to a piece of equipment on bootup, then switch in a relay to let the pc take over. It works and I just wanted to use up the 628A's that I got stuck with.
Thanks For the help.
Ringo _________________ Ringo Davis |
|
|
|