|
|
View previous topic :: View next topic |
Author |
Message |
achilles03
Joined: 23 Apr 2010 Posts: 7 Location: Huntsville, AL
|
Compiler problems? |
Posted: Fri Apr 23, 2010 9:00 pm |
|
|
I'm completely new to programming PICs in C (used others), but am working on modifying some existing code that I'm interested in using for a project
When I program the PIC with the original hex file (created in 2004) to a 16F628A, it works no problem. When I use the PCWHD compiler, I get a hex file that freezes mid-program when it runs on the PIC. It compiles without error, and 3 minor warnings:
Line 897(1,1) Code has no effect
Line 1216(1,5): Function not void and does not return a value MAIN
Line186(62,69): Variable never used: config1
Specifically, when it's getting an invalid GPS signal, it gives a normal "invalid" heartbeat via an LED. When the GPS starts providing valid data, it goes into transmit mode (which it's supposed to do), but freezes at that point.
Any clue to what issues with the compiler are occurring?
Thanks in advance for any help!
Dave |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 23, 2010 9:45 pm |
|
|
What's the old version, and what's the new version of the compiler ?
Make sure you don't have a local copy of the old 16F628A.h file in your
project directory. The newer compiler version almost certainly has
different values for some of constants in the .H file. If you use the old .H
file, the functions won't be compiled correctly.
Delete any 16F628A.H file in your project directory. Let the compiler use
the current .H file, in the c:\Program Files\Picc\Devices directory. |
|
|
achilles03
Joined: 23 Apr 2010 Posts: 7 Location: Huntsville, AL
|
|
Posted: Fri Apr 23, 2010 10:02 pm |
|
|
PCM programmer wrote: | What's the old version, and what's the new version of the compiler ?
Make sure you don't have a local copy of the old 16F628A.h file in your
project directory. The newer compiler version almost certainly has
different values for some of constants in the .H file. If you use the old .H
file, the functions won't be compiled correctly.
Delete any 16F628A.H file in your project directory. Let the compiler use
the current .H file, in the c:\Program Files\Picc\Devices directory. |
That might be the problem! I'm not sure what the older version was, but I'm compiling with 4.093.
I'm listing the original .h files. The header files aren't too long, so if there's any obvious out-of-date code, I'd really appreciate knowing!
Thanks again,
Dave
Code: |
#define TTvers 0x10 // x.y (1.0), upper 4 bits = x, lower 4 bits = y
#define 1200LoopLength = 33 // Used in sendbyte to control 1200Hz bit time
#define 2200LoopLength = 59 // Used in sendbyte to control 2200Hz bit time
#define cd PIN_A0
#define valid PIN_A1
#define ptt_out PIN_A2
#define sout PIN_A3
#define sin PIN_A4
#define r8k PIN_B0
#define r4k PIN_B1
#define r2k PIN_B2
#define r1k PIN_B3
#define audio PIN_B4
#define ptt_in PIN_B5
#define sw1 PIN_B6
#define sw2 PIN_B7
// The from and path info below are a series of 7 byte values.
// Each has 6 letters/numbers followed by an SSID. No SSID is
// indicated by an ASCII zero.
//
// If callsigns of less than 6 chars are used then spaces must be
// added to pad to six. For example,
// K5ATM-3 is stored as K5ATM<space>3
// WIDE is stored as WIDE<space><space>0
// WIDE3-3 is stored as WIDE3<space>3
//
// All values are multiplied by 2 per the X.25 specification
// (the LSB of each byte must be 0 for extended addressing)
//
// The SSID must be between 0 and 15 and is formatted as follows:
// MSB LSB
// 0 1 1 S S I D 0
//
// b7 is a flag used by repeaters. We set it to 0
// b6-b5 are reserved and should be set to 1
// b4-b1 = SSID (0 to 15)
// b0 = zero (for extended addressing)
//
// The easy way to generate the (encoded) SSID is to say
// encoded SSID = (0x30 + SSID) * 2
// encoded SSID = (ASCII zero + SSID) * 2
// If we want an SSID of 11 we use 0x3b * 2 = 0x76
//
// The last byte in the path has an LSB of 1
//
//
// Path Info
//
#define EEfrom 0x00
#rom 0x2100 = {'M'*2,'Y'*2,'C'*2,'A'*2,'L'*2,'L'*2,0x7E}
#rom 0x2107 = {'W'*2,'I'*2,'D'*2,'E'*2,'3'*2,' '*2,'3'*2+1}
#rom 0x210E = {0,0,0,0,0,0,0}
#rom 0x2115 = {0,0,0,0,0,0,0}
//
// Config 1 Info
//
#define EEsymbtab1 0x1C // "/" is primary table, "\" is secondary table
#define EEsym1 0x1D
#rom 0x211C = {'/', '$'}
#define EEtrate1 0x1E
#rom 0x211E = {1} // Packet transmitted every <value> * 10 seconds
#define EEbrate1 0x1F
#rom 0x211F = {3} // Beacon rate. 3=> every third packet has comment
//
// Config 2 info
//
#define EEsymbtab2 0x20
#define EEsym2 0x21
#rom 0x2120 = {'\\', '$'} // Symbol
#define EEtrate2 0x22
#rom 0x2122 = {2} // Packet transmitted every <value> * 10 seconds
//
// Config info common to Config 1 and Config 2
//
#define EEbrate2 0x23
#rom 0x2123 = {1} // Beacon rate. 1=> every packet has comment
#define EEqtime 0x24 // Channel must remain quite for this
#rom 0x2124 = {7} // number of 1/10 seconds before xmit is allowed
#define EExdelay 0x25 // This many flags are sent before data is xmitted
#rom 0x2125 = {40} // Each flag is about 850us
#define EEtone1200 0x26
#rom 0x2126 = {0Xff-51} // for a nominal 1219.23Hz
#define EEdink12 0x27 // 1200Hz fine tune parameter
#rom 0x2127 = {0x01}
#define EEtone2200 0x28
#rom 0x2128 = {0xff-21} // for a nominal 2232.14Hz
#define EEdink22 0x29
#rom 0x2129 = {0x02} // 2200 Hz fine tune parameter
//
// Use remaining EEPROM for a comment
//
#define EEcomment 0x2A
#rom 0x212A = {'M', 'i', 'k', 'e', ' ', 'f', 'r', 'o'}
#rom 0x2132 = {'m', ' ', 'A', 'b', 'q', ' ', 'N', 'M'}
#rom 0x213A = {0,0,0,0,0}
#define EElastByte 0x3F //Comment string ends with a zero
#rom 0x213F = {0} |
SECOND .H FILE:
Code: |
#device PIC16F628
#FUSES HS,NOPROTECT,NOWDT,PUT
#use delay(clock=10000000)
#nolist
/////////////////////////////// I/O definitions for INPUT() and OUTPUT_xxx()
#define PIN_A0 40
#define PIN_A1 41
#define PIN_A2 42
#define PIN_A3 43
#define PIN_A4 44
#define PIN_B0 48
#define PIN_B1 49
#define PIN_B2 50
#define PIN_B3 51
#define PIN_B4 52
#define PIN_B5 53
#define PIN_B6 54
#define PIN_B7 55
#byte timr0 = 1
#byte status = 3
#byte porta = 5
#byte portb = 6
#define CMCON 0x1F // Used to enable port A for digital on 16F628
/////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1
#define BYTE int
#define BOOL short int
#define getc getch
#define getchar getch
#define puts(s) {printf(s); putchar(13); putchar(10);}
#define putc putchar
/////////////////////////////// Constants used for RESTART_CAUSE()
#define WDT_FROM_SLEEP 0
#define WDT_TIMEOUT 8
#define MCLR_FROM_SLEEP 16
#define NORMAL_POWER_UP 24
/////////////////////////////// Constants used for SETUP_COUNTERS()
#define RTCC_INTERNAL 0
#define RTCC_EXT_L_TO_H 32
#define RTCC_EXT_H_TO_L 48
#define RTCC_DIV_2 0
#define RTCC_DIV_4 1
#define RTCC_DIV_8 2
#define RTCC_DIV_16 3
#define RTCC_DIV_32 4
#define RTCC_DIV_64 5
#define RTCC_DIV_128 6
#define RTCC_DIV_256 7
#define WDT_18MS 8
#define WDT_36MS 9
#define WDT_72MS 10
#define WDT_144MS 11
#define WDT_288MS 12
#define WDT_576MS 13
#define WDT_1152MS 14
#define WDT_2304MS 15
#define L_TO_H 0x40
#define H_TO_L 0
#define RTCC_ZERO 0x0B20 // Used for ENABLE/DISABLE INTERRUPTS
#define RB_CHANGE 0x0B08 // Used for ENABLE/DISABLE INTERRUPTS
#define EXT_INT 0x0B10 // Used for ENABLE/DISABLE INTERRUPTS
#define GLOBAL 0x0BC0 // Used for ENABLE/DISABLE INTERRUPTS
#list
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|