|
|
View previous topic :: View next topic |
Author |
Message |
pirev
Joined: 19 Mar 2005 Posts: 13 Location: Bulgaria
|
Bug in CCS 3.245 for interrupt vectors |
Posted: Mon May 15, 2006 1:37 pm |
|
|
Hi all,
here is piece from my program:
Code: |
#include <16f913.h>
#CASE
int8 frtcc, catod, Display, i,
rtcc10ms, rtcc100ms,
rtcc1s, rtcc1m,
iTemp;
char const szLedTable=29;
char const LedTable[szLedTable] = {
0x3F, 0x06, 0x5B, 0x4F, // characters 0,1,2 & 3
0x66, 0x6D, 0x7D, 0x07, // characters 4,5,6 & 7
0x7F, 0x6F, 0x77, 0x7C, // characters 8,9,A,B
0x39, 0x5E, 0x79, 0x71, // characters C,D,E,F
0x78, 0x76, 0x73, 0x38, // characters T,H,P,L
0x01, 0x41, 0x49, 0x00, // Upper line,Upper & Middle line, Upper,Middle & Bottom line, NO DIGIT
0x1C, 0x54, 0x5C, 0x50, // 'u', 'n', 'o', 'r'
0x80
};
int8 DisplayPattern[szLedTable];
// Reserve RAM to save in interrupt vector W,STATUS,PCLATH & FSR registers
#RESERVE 0x7C,0x7D,0x7E,0x7F
#RESERVE 0xFC,0xFD,0xFE,0xFF
#BYTE Wtemp=0x7C
#BYTE STATUStemp=0x7D
#BYTE PCLATHtemp=0x7E
#BYTE FSRtemp=0x7F
inline void PushOntoStack(void) {
#asm
movwf Wtemp // Store W-reg
swapf STATUS,W // Swap status to be saved into W
clrf STATUS // bank 0, Clears IRP,RP1,RP0
movwf STATUStemp // Save status to bank zero STATUS_TEMP
movf PCLATH,W // pages 1, 2 and/or 3
movwf PCLATHtemp // Save PCLATH into W
clrf PCLATH // Page zero, regardless of current page
movf FSR,W // Copy FSR to W
movwf FSRtemp // Copy FSR from W to FSR_TEMP
#endasm
}
inline void PopFromStack(void) {
#asm
clrf STATUS // bank0
movf FSRtemp,W // Restore FSR register
movwf FSR
movf PCLATHtemp,W // Restore PCLATH
movwf PCLATH // Move W into PCLATH
swapf STATUStemp,W // Swap STATUS_TEMP register into W
// (sets bank to original state)
movwf STATUS // Move W into STATUS register
swapf Wtemp,F // Swap W_TEMP
swapf Wtemp,W // Swap W_TEMP into W
retfie // end of interrupt vector
#endasm
}
#INT_GLOBAL
void InterruptHandler(void) // Global interrupt vector for PIC16
{
PushOntoStack(); // Store registers in 'Stack'
if( T0IF ) {
TMR0 = 162;
T0IF = 0;
/*
...
Some program code
...
*/
}
PopFromStack(); // Restore registers from 'Stack'
}
void LoadDisplayPattern(void) {
i = 0;
do {
DisplayPattern[i] = LedTable[i];
} while( ++i < szLedTable );
}
void InitHardware(void) {
OPTION_REG = 0x84; // 1:32, pull up disable,
catod = 1;
LoadDisplayPattern();
TMR0 = 162;
T0IF = 0; T0IE = 1;
INTCON |= 0xC0; // Enable all unmasked interrupts
}
void main(void) {
InitHardware();
while( 1 ) {
/*
...
Some program code
...
*/
}
}
|
and here is a piece from listing:
Code: |
MPASM
CCS PCM C Compiler, Version 3.245, 28193 15-Ìàé-06 22:35
Filename: C:\myfile\prog\pic\c\ccsc\proba.lst
ROM used: 109 words (3%)
Largest free fragment is 2048
RAM used: 46 (26%) at main() level
47 (27%) worst case
Stack: 3 worst case (2 in main + 1 for interrupts)
0000 3000 00001 MOVLW 00
0001 008A 00002 MOVWF 0A
0002 2859 00003 GOTO 059
0003 0000 00004 NOP
0000 00005 .................... #include <16f913.h>
0000 00006 .................... //////// Standard Header file for the PIC16F913 device ////////////////
0000 00007 .................... //#device PIC16F913
0000 00008 .................... #device PIC16F913
0004 100A 00009 BCF 0A.0
0005 108A 00010 BCF 0A.1
0006 110A 00011 BCF 0A.2
0007 0782 00012 ADDWF 02,F
0008 343F 00013 RETLW 3F
0009 3406 00014 RETLW 06
000A 345B 00015 RETLW 5B
000B 344F 00016 RETLW 4F
000C 3466 00017 RETLW 66
000D 346D 00018 RETLW 6D
000E 347D 00019 RETLW 7D
000F 3407 00020 RETLW 07
0010 347F 00021 RETLW 7F
0011 346F 00022 RETLW 6F
0012 3477 00023 RETLW 77
0013 347C 00024 RETLW 7C
0014 3439 00025 RETLW 39
0015 345E 00026 RETLW 5E
0016 3479 00027 RETLW 79
0017 3471 00028 RETLW 71
0018 3478 00029 RETLW 78
0019 3476 00030 RETLW 76
001A 3473 00031 RETLW 73
001B 3438 00032 RETLW 38
001C 3401 00033 RETLW 01
001D 3441 00034 RETLW 41
001E 3449 00035 RETLW 49
001F 3400 00036 RETLW 00
0020 341C 00037 RETLW 1C
0021 3454 00038 RETLW 54
0022 345C 00039 RETLW 5C
0023 3450 00040 RETLW 50
0024 3480 00041 RETLW 80
0000 00042 .................... #define __16F913
0000 00724 .................... #list
0000 00725 ....................
0000 00726 .................... #CASE
0000 00727 ....................
0000 00728 .................... int8 frtcc, catod, Display, i,
0000 00729 .................... rtcc10ms, rtcc100ms,
0000 00730 .................... rtcc1s, rtcc1m,
0000 00731 .................... iTemp;
0000 00732 ....................
0000 00733 .................... char const szLedTable=29;
0000 00734 .................... char const LedTable[szLedTable] = {
0000 00735 .................... 0x3F, 0x06, 0x5B, 0x4F, // characters 0,1,2 & 3
0000 00736 .................... 0x66, 0x6D, 0x7D, 0x07, // characters 4,5,6 & 7
0000 00737 .................... 0x7F, 0x6F, 0x77, 0x7C, // characters 8,9,A,B
0000 00738 .................... 0x39, 0x5E, 0x79, 0x71, // characters C,D,E,F
0000 00739 .................... 0x78, 0x76, 0x73, 0x38, // characters T,H,P,L
0000 00740 .................... 0x01, 0x41, 0x49, 0x00, // Upper line,Upper & Middle line, Upper,Middle & Bottom line, NO DIGIT
0000 00741 .................... 0x1C, 0x54, 0x5C, 0x50, // 'u', 'n', 'o', 'r'
0000 00742 .................... 0x80
0000 00743 .................... };
0000 00744 ....................
0000 00745 .................... int8 DisplayPattern[szLedTable];
0000 00746 ....................
0000 00747 .................... // Reserve RAM to save in interrupt vector W,STATUS,PCLATH & FSR registers
0000 00748 .................... #RESERVE 0x7C,0x7D,0x7E,0x7F
0000 00749 .................... #RESERVE 0xFC,0xFD,0xFE,0xFF
0000 00750 .................... #BYTE Wtemp=0x7C
0000 00751 .................... #BYTE STATUStemp=0x7D
0000 00752 .................... #BYTE PCLATHtemp=0x7E
0000 00753 .................... #BYTE FSRtemp=0x7F
0000 00754 ....................
0000 00755 .................... inline void PushOntoStack(void) {
0000 00756 .................... #asm
0000 00757 .................... movwf Wtemp // Store W-reg
0025 00FC 00758 MOVWF 7C
0000 00759 .................... swapf STATUS,W // Swap status to be saved into W
0026 0E03 00760 SWAPF 03,W
0000 00761 .................... clrf STATUS // bank 0, Clears IRP,RP1,RP0
0027 0183 00762 CLRF 03
0000 00763 .................... movwf STATUStemp // Save status to bank zero STATUS_TEMP
0028 00FD 00764 MOVWF 7D
0000 00765 .................... movf PCLATH,W // pages 1, 2 and/or 3
0029 080A 00766 MOVF 0A,W
0000 00767 .................... movwf PCLATHtemp // Save PCLATH into W
002A 00FE 00768 MOVWF 7E
0000 00769 .................... clrf PCLATH // Page zero, regardless of current page
002B 018A 00770 CLRF 0A
0000 00771 .................... movf FSR,W // Copy FSR to W
002C 0804 00772 MOVF 04,W
0000 00773 .................... movwf FSRtemp // Copy FSR from W to FSR_TEMP
002D 00FF 00774 MOVWF 7F
0000 00775 .................... #endasm
0000 00776 .................... }
|
My array LedTable is placed at address 0x0004, where must be placed code for interrupt vector ( I'm using #INT_GLOBAL ), and code for interrupt vector started from address 0x0025. Before version 3.245 I was used 3.241 and there are no problem with #INT_GLOBAL definition and constants in ROM area. |
|
|
Ttelmah Guest
|
|
Posted: Mon May 15, 2006 3:14 pm |
|
|
Add and 'enable_interrupt' in your main. You will then find that the compiler handles the interrupts correctly.
The optimiser sees that the interrupts are never enabled, and does not therefore bother to 'look' for the interrupt keywords. Turning down the optimiser will also fix this.
As a general 'comment', you can just declare the temp registers as integers, and not waste the space declaring them as you do. Alternatively use '#locate', which acts like the combination of a byte, and reserve declaration together. Get rid of the retfie in your 'pop' code, the compiler automatically adds a retfie at the end of the interrupt routine.
Best Wishes |
|
|
pirev
Joined: 19 Mar 2005 Posts: 13 Location: Bulgaria
|
|
Posted: Mon May 15, 2006 4:10 pm |
|
|
Thanks Ttelmah,
enable_interrupts(GLOBAL) generate the same code as
INTCON |= 0xC0; in my function InitHardware();
Also I set #OPT 0, but situation are not changed. At address 0x0004 compiler place my array LedTable, but not interrupt vector. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 15, 2006 4:54 pm |
|
|
Your code is not compilable, as posted. It's missing the declarations
for STATUS, PCLATH, TMR0, etc. Also, the pre-processor statements
for "inline" are missing the "#" symbol that should be in front of them.
It looks like the problem is caused by a bug in vs. 3.245, because I
tested it with PCM vs. 3.249 and it works OK.
However, it looks like you can fix the problem with 3.245 by using
an #org statement to move the LedTable to another location in ROM.
Then the compiler puts the #int_global code at address 0x0004.
Add the line shown in bold below:
Quote: |
#org 0x100, 0x12F
char const LedTable[szLedTable] = {
0x3F, 0x06, 0x5B, 0x4F, // characters 0,1,2 & 3
0x66, 0x6D, 0x7D, 0x07, // characters 4,5,6 & 7
0x7F, 0x6F, 0x77, 0x7C, // characters 8,9,A,B
0x39, 0x5E, 0x79, 0x71, // characters C,D,E,F
0x78, 0x76, 0x73, 0x38, // characters T,H,P,L
0x01, 0x41, 0x49, 0x00, // Upper line
0x1C, 0x54, 0x5C, 0x50, // 'u', 'n', 'o', 'r'
0x80
}; |
|
|
|
pirev
Joined: 19 Mar 2005 Posts: 13 Location: Bulgaria
|
|
Posted: Mon May 15, 2006 11:30 pm |
|
|
Thanks PCM programmer,
PCM programmer wrote: | Your code is not compilable, as posted. It's missing the declarations
for STATUS, PCLATH, TMR0, etc. Also, the pre-processor statements
for "inline" are missing the "#" symbol that should be in front of them.
|
STATUS, PCLATH, TMR0 and etc, and declared in modifyed 16913.h:
Code: |
//////// Standard Header file for the PIC16F913 device ////////////////
#device PIC16F913
#define __16F913
#nolist
//////// Program memory: 4096x14 Data RAM: 351 Stack: 8
//////// I/O: 25 Analog Pins: 5
//////// Data EEPROM: 256
//////// C Scratch area: 77 ID Location: 2000
//////// Fuses: LP,XT,HS,EC,NOWDT,WDT,NOPUT,PUT,PROTECT,NOPROTECT,MCLR
//////// Fuses: NOMCLR,CPD,NOCPD,BROWNOUT,BROWNOUT_SW,BROWNOUT_NOSL
//////// Fuses: NOBROWNOUT,IESO,NOIESO,FCMEN,NOFCMEN,DEBUG,NODEBUG,INTRC_IO
//////// Fuses: INTRC,RC_IO,RC
////////
////////////////////////////////////////////////////////////////// I/O
// Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
// PORT_B_PULLUPS(), INPUT(),
// OUTPUT_LOW(), OUTPUT_HIGH(),
// OUTPUT_FLOAT(), OUTPUT_BIT()
// Constants used to identify pins in the above are:
#define PIN_A0 40
#define PIN_A1 41
#define PIN_A2 42
#define PIN_A3 43
#define PIN_A4 44
#define PIN_A5 45
#define PIN_A6 46
#define PIN_A7 47
#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
#define PIN_C0 56
#define PIN_C1 57
#define PIN_C2 58
#define PIN_C3 59
#define PIN_C4 60
#define PIN_C5 61
#define PIN_C6 62
#define PIN_C7 63
#define PIN_E3 75
////////////////////////////////////////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1
#define BYTE int
#define BOOLEAN short int
#define getc getch
#define fgetc getch
#define getchar getch
#define putc putchar
#define fputc putchar
#define fgets gets
#define fputs puts
////////////////////////////////////////////////////////////////// Control
// Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
// Constants returned from RESTART_CAUSE() are:
#define WDT_FROM_SLEEP 0
#define WDT_TIMEOUT 8
#define MCLR_FROM_SLEEP 16
#define NORMAL_POWER_UP 24
////////////////////////////////////////////////////////////////// Timer 0
// Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER_0(),
// SET_TIMER0() or SET_RTCC(),
// GET_TIMER0() or GET_RTCC()
// Constants used for SETUP_TIMER_0() are:
#define RTCC_INTERNAL 0
#define RTCC_EXT_L_TO_H 32
#define RTCC_EXT_H_TO_L 48
#define RTCC_DIV_1 8
#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 RTCC_8_BIT 0
// Constants used for SETUP_COUNTERS() are the above
// constants for the 1st param and the following for
// the 2nd param:
////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
//
#define WDT_ON 1
#define WDT_OFF 0
#define WDT_DIV_32 0
#define WDT_DIV_64 2
#define WDT_DIV_128 4
#define WDT_DIV_256 6
#define WDT_DIV_512 8
#define WDT_DIV_1024 10
#define WDT_DIV_2048 12
#define WDT_DIV_4096 14
#define WDT_DIV_8192 16
#define WDT_DIV_16394 18
#define WDT_DIV_32768 20
#define WDT_DIV_65536 22
////////////////////////////////////////////////////////////////// Timer 1
// Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1
// Constants used for SETUP_TIMER_1() are:
// (or (via |) together constants from each group)
#define T1_DISABLED 0
#define T1_INTERNAL 0x85
#define T1_EXTERNAL 0x87
#define T1_EXTERNAL_SYNC 0x83
#define T1_CLK_OUT 8
#define T1_DIV_BY_1 0
#define T1_DIV_BY_2 0x10
#define T1_DIV_BY_4 0x20
#define T1_DIV_BY_8 0x30
////////////////////////////////////////////////////////////////// Timer 2
// Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2
// Constants used for SETUP_TIMER_2() are:
#define T2_DISABLED 0
#define T2_DIV_BY_1 4
#define T2_DIV_BY_4 5
#define T2_DIV_BY_16 6
////////////////////////////////////////////////////////////////// CCP
// CCP Functions: SETUP_CCPx, SET_PWMx_DUTY
// CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH
// Constants used for SETUP_CCPx() are:
#define CCP_OFF 0
#define CCP_CAPTURE_FE 4
#define CCP_CAPTURE_RE 5
#define CCP_CAPTURE_DIV_4 6
#define CCP_CAPTURE_DIV_16 7
#define CCP_COMPARE_SET_ON_MATCH 8
#define CCP_COMPARE_CLR_ON_MATCH 9
#define CCP_COMPARE_INT 0xA
#define CCP_COMPARE_RESET_TIMER 0xB
#define CCP_PWM 0xC
#define CCP_PWM_PLUS_1 0x1c
#define CCP_PWM_PLUS_2 0x2c
#define CCP_PWM_PLUS_3 0x3c
long CCP_1;
#byte CCP_1 = 0x15
#byte CCP_1_LOW= 0x15
#byte CCP_1_HIGH= 0x16
////////////////////////////////////////////////////////////////// SPI
// SPI Functions: SETUP_SPI, SPI_WRITE, SPI_READ, SPI_DATA_IN
// Constants used in SETUP_SSP() are:
#define SPI_MASTER 0x20
#define SPI_SLAVE 0x24
#define SPI_L_TO_H 0
#define SPI_H_TO_L 0x10
#define SPI_CLK_DIV_4 0
#define SPI_CLK_DIV_16 1
#define SPI_CLK_DIV_64 2
#define SPI_CLK_T2 3
#define SPI_SS_DISABLED 1
#define SPI_SAMPLE_AT_END 0x8000
#define SPI_XMIT_L_TO_H 0x4000
////////////////////////////////////////////////////////////////// UART
// Constants used in setup_uart() are:
// FALSE - Turn UART off
// TRUE - Turn UART on
#define UART_ADDRESS 2
#define UART_DATA 4
////////////////////////////////////////////////////////////////// COMP
// Comparator Variables: C1OUT, C2OUT
// Constants used in setup_comparators() are:
#define A0_A3_A1_A3 0xfff04
#define A0_A3_A1_A2_OUT_ON_A4_A5 0xfcf03
#define A0_A3_A1_A3_OUT_ON_A4_A5 0xbcf05
#define NC_NC_NC_NC 0x0ff07
#define A0_A3_A1_A2 0xfff02
#define A0_A3_NC_NC_OUT_ON_A4 0x9ef01
#define A0_VR_A1_VR 0x3ff06
#define A3_VR_A2_VR 0xcff0e
#bit C1OUT = 0x9c.6
#bit C2OUT = 0x9c.7
////////////////////////////////////////////////////////////////// VREF
// Constants used in setup_vref() are:
//
#define VREF_LOW 0xa0
#define VREF_HIGH 0x80
// Or (with |) the above with a number 0-15
#define VREF_A2 0x40
////////////////////////////////////////////////////////////////// VREF
// Constants used in setup_low_volt_detect() are:
//
#define LVD_LVDIN 0x1F
#define LVD_45 0x1E
#define LVD_42 0x1D
#define LVD_40 0x1C
#define LVD_38 0x1B
#define LVD_36 0x1A
#define LVD_35 0x19
#define LVD_33 0x18
#define LVD_30 0x17
#define LVD_28 0x16
#define LVD_27 0x15
#define LVD_25 0x14
////////////////////////////////////////////////////////////////// LCD
// LCD Functions: SETUP_LCD, LCD_SYMBOL, LCD_LOAD
// Constants used in setup_lcd() are:
#define LCD_DISABLED 0
#define LCD_STATIC 0x80
#define LCD_MUX12 0x81
#define LCD_MUX13 0x82
#define LCD_MUX14 0x83
#define STOP_ON_SLEEP 0x40
#define USE_TIMER_1 0x04
#define SEG0_4 1
#define SEG5_8 2
#define SEG9_11 4
#define SEG12_15 8
#define SEG16_19 16
#define SEG20_26 32
#define SEG27_28 64
#define SEG29_31 128
#define ALL_LCD_PINS 255
// Constants used in lcd_symbol() are:
#define COM0 0
#define COM1 32
#define COM2 64
#define COM3 96
////////////////////////////////////////////////////////////////// INTERNAL RC
// Constants used in setup_oscillator() are:
#define OSC_31KHZ 0
#define OSC_125KHZ 0x10
#define OSC_250KHZ 0x20
#define OSC_500KHZ 0x30
#define OSC_1MHZ 0x40
#define OSC_2MHZ 0x50
#define OSC_4MHZ 0x60
#define OSC_8MHZ 0x70
// The following may be OR'ed in with the above using |
#define OSC_TIMER1 1
#define OSC_INTRC 2
#define OSC_NORMAL 0
// A second optional parametter may be used with this part to fine
// tune the speed (signed int)
// Result may be (ignore all other bits)
#define OSC_STATE_STABLE 4
////////////////////////////////////////////////////////////////// ADC
// ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS() (aka SETUP_PORT_A),
// SET_ADC_CHANNEL(), READ_ADC()
// Constants used for SETUP_ADC() are:
#define ADC_OFF 0 // ADC Off
#define ADC_CLOCK_DIV_2 0x100
#define ADC_CLOCK_DIV_4 0x40
#define ADC_CLOCK_DIV_8 0x10
#define ADC_CLOCK_DIV_32 0x20
#define ADC_CLOCK_DIV_16 0x50
#define ADC_CLOCK_DIV_64 0x60
#define ADC_CLOCK_INTERNAL 0x30 // Internal 2-6us
// Constants used in SETUP_ADC_PORTS() are:
#define sAN0 1 //| A0
#define sAN1 2 //| A1
#define sAN2 4 //| A2
#define sAN3 8 //| A3
#define sAN4 16 //| A5
#define NO_ANALOGS 0 // None
#define ALL_ANALOG 31 // A0 A1 A2 A3 A5
// One of the following may be OR'ed in with the above using |
#define VSS_VDD 0x0000 // Range 0-Vdd
#define VREF_VREF 0x6000 // Range VrefL-VrefH
#define VSS_VREF 0x2000 // Range 0-VrefH
#define VREF_VDD 0x4000 // Range VrefL-Vdd
// Constants used in READ_ADC() are:
#define ADC_START_AND_READ 7 // This is the default if nothing is specified
#define ADC_START_ONLY 1
#define ADC_READ_ONLY 6
////////////////////////////////////////////////////////////////// INT
// Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
// EXT_INT_EDGE()
//
// Constants used in EXT_INT_EDGE() are:
#define L_TO_H 0x40
#define H_TO_L 0
// Constants used in ENABLE/DISABLE_INTERRUPTS() are:
#define GLOBAL 0x0BC0
#define INT_RTCC 0x0B20
#define INT_RB 0x0B08
#define INT_EXT 0x0B10
#define INT_AD 0x8C40
#define INT_TBE 0x8C10
#define INT_RDA 0x8C20
#define INT_TIMER1 0x8C01
#define INT_TIMER2 0x8C02
#define INT_CCP1 0x8C04
#define INT_SSP 0x8C08
#define INT_TIMER0 0x0B20
#define INT_EEPROM 0x8C80
#define INT_OSC_FAIL 0x8D80
#define INT_LCD 0x8D10
#define INT_LOWVOLT 0x8D04
#define INT_COMP 0x8D20
#define INT_COMP2 0x8D40
#define INT_RA0 0x010B08
#define INT_RA1 0x020B08
#define INT_RA2 0x040B08
#define INT_RA3 0x080B08
#define INT_RA4 0x100B08
#define INT_RA5 0x200B08
#define INT_RA6 0x400B08
#define INT_RA7 0x800B08
#define INT_RB0 0x010B08
#define INT_RB1 0x020B08
#define INT_RB2 0x040B08
#define INT_RB3 0x080B08
#define INT_RB4 0x100B08
#define INT_RB5 0x200B08
#define INT_RB6 0x400B08
#define INT_RB7 0x800B08
#list
//----- Interrupt Vectors -------------------------------------------------
//#BYTE __RESET = 0x0000
//#BYTE __INT = 0x0004
//----- Special Function Registers ----------------------------------------
#BYTE INDF = 0x00
#BYTE TMR0 = 0x01
#BYTE PCL = 0x02
#BYTE STATUS = 0x03
#BYTE FSR = 0x04
#BYTE PORTA = 0x05
#BYTE PORTB = 0x06
#BYTE PORTC = 0x07
#BYTE PORTE = 0x09
#BYTE PCLATH = 0x0A
#BYTE INTCON = 0x0B
#BYTE PIR1 = 0x0C
#BYTE PIR2 = 0x0D
#BYTE TMR1L = 0x0E
#BYTE TMR1H = 0x0F
#BYTE T1CON = 0x10
#BYTE TMR2 = 0x11
#BYTE T2CON = 0x12
#BYTE SSPBUF = 0x13
#BYTE SSPCON = 0x14
#BYTE CCPR1L = 0x15
#BYTE CCPR1H = 0x16
#BYTE CCP1CON = 0x17
#BYTE RCSTA = 0x18
#BYTE TXREG = 0x19
#BYTE RCREG = 0x1A
#BYTE CCPR2L = 0x1B
#BYTE CCPR2H = 0x1C
#BYTE CCP2CON = 0x1D
#BYTE ADRES = 0x1E
#BYTE ADRESH = 0x1E
#BYTE ADCON0 = 0x1F
#BYTE OPTION_REG = 0x81
#BYTE TRISA = 0x85
#BYTE TRISB = 0x86
#BYTE TRISC = 0x87
#BYTE TRISE = 0x89
#BYTE PIE1 = 0x8C
#BYTE PIE2 = 0x8D
#BYTE PCON = 0x8E
#BYTE OCSCON = 0x8F
#BYTE OSCTUNE = 0x90
#BYTE ANSEL = 0x91
#BYTE PR2 = 0x92
#BYTE SSPADD = 0x93
#BYTE SSPSTAT = 0x94
#BYTE WPUB = 0x95
#BYTE IOCB = 0x96
#BYTE CMCON1 = 0x97
#BYTE TXSTA = 0x98
#BYTE SPBRG = 0x99
#BYTE CMCON0 = 0x9C
#BYTE VRCON = 0x9D
#BYTE ADRESL = 0x9E
#BYTE ADCON1 = 0x9F
#BYTE WDTCON = 0x105
#BYTE LCDCON = 0x107
#BYTE LCDPS = 0x108
#BYTE LVDCON = 0x109
#BYTE EEDATA = 0x10C
#BYTE EEADR = 0x10D
#BYTE EEDATH = 0x10E
#BYTE EEADRH = 0x10F
#BYTE EECON1 = 0x18C
#BYTE EECON2 = 0x18D
#BYTE LCDDATA0 = 0x110
#BYTE LCDDATA1 = 0x111
#BYTE LCDDATA3 = 0x113
#BYTE LCDDATA4 = 0x114
#BYTE LCDDATA6 = 0x116
#BYTE LCDDATA7 = 0x117
#BYTE LCDDATA9 = 0x119
#BYTE LCDDATA10 = 0x11A
#BYTE LCDSE0 = 0x11C
#BYTE LCDSE1 = 0x11D
//----- STATUS Bits -------------------------------------------------------
#bit _C=STATUS.0
#bit _DC=STATUS.1
#bit _Z=STATUS.2
#bit _NOT_PD=STATUS.3
#bit _PD_=STATUS.3
#bit _NOT_TO=STATUS.4
#bit _TO_=STATUS.4
#bit _RP0=STATUS.5
#bit _RP1=STATUS.6
#bit _IRP=STATUS.7
//----- PORTA Bits --------------------------------------------------------
//#bit AN0=PORTA.0
#bit AN1=PORTA.1
#bit AN2=PORTA.2
#bit AN3=PORTA.3
#bit T0CKI=PORTA.4
#bit AN4=PORTA.5
#bit SS_=PORTA.5
//----- PORTB Bits --------------------------------------------------------
#bit EINT=PORTB.0
//----- PORTC Bits --------------------------------------------------------
#bit T1CKI=PORTC.0
#bit T1OSO=PORTC.0
#bit T1OSI=PORTC.1
#bit CCP2=PORTC.1
#bit CCP1=PORTC.2
#bit SCK=PORTC.3
#bit SCL=PORTC.3
#bit SDI=PORTC.4
#bit SDA=PORTC.4
#bit SDO=PORTC.5
#bit TX=PORTC.6
#bit CK=PORTC.6
#bit RX=PORTC.7
#bit DT=PORTC.7
//----- INTCON Bits -------------------------------------------------------
#bit RBIF=INTCON.0
#bit INTF=INTCON.1
#bit T0IF=INTCON.2
#bit RBIE=INTCON.3
#bit INTE=INTCON.4
#bit T0IE=INTCON.5
#bit PEIE=INTCON.6
#bit GIE=INTCON.7
//----- PIR1 Bits ---------------------------------------------------------
#bit TMR1IF=PIR1.0
#bit TMR2IF=PIR1.1
#bit CCP1IF=PIR1.2
#bit SSPIF=PIR1.3
#bit TXIF=PIR1.4
#bit RCIF=PIR1.5
#bit ADIF=PIR1.6
#bit PSPIF=PIR1.7
//----- PIR2 Bits ---------------------------------------------------------
#bit CCP2IF=PIR2.0
#bit BCLIF =PIR2.3
#bit EEIF =PIR2.4
//----- T1CON Bits --------------------------------------------------------
#bit TMR1ON=T1CON.0
#bit TMR1CS=T1CON.1
#bit NOT_T1SYNC=T1CON.2
#bit T1INSYNC=T1CON.2
#bit T1OSCEN=T1CON.3
#bit T1CKPS0=T1CON.4
#bit T1CKPS1=T1CON.5
//----- T2CON Bits --------------------------------------------------------
#bit T2CKPS0=T2CON.0
#bit T2CKPS1=T2CON.1
#bit TMR2ON=T2CON.2
#bit TOUTPS0=T2CON.3
#bit TOUTPS1=T2CON.4
#bit TOUTPS2=T2CON.5
#bit TOUTPS3=T2CON.6
//----- SSPCON Bits -------------------------------------------------------
#bit SSPM0=SSPCON.0
#bit SSPM1=SSPCON.1
#bit SSPM2=SSPCON.2
#bit SSPM3=SSPCON.3
#bit CKP=SSPCON.4
#bit SSPEN=SSPCON.5
#bit SSPOV=SSPCON.6
#bit WCOL=SSPCON.7
//----- CCP1CON Bits ------------------------------------------------------
#bit CCP1M0=CCP1CON.0
#bit CCP1M1=CCP1CON.1
#bit CCP1M2=CCP1CON.2
#bit CCP1M3=CCP1CON.3
#bit CCP1Y=CCP1CON.4
#bit CCP1X=CCP1CON.5
//----- RCSTA Bits --------------------------------------------------------
#bit RCD8=RCSTA.0
#bit RX9D=RCSTA.0
#bit OERR=RCSTA.1
#bit FERR=RCSTA.2
#bit CREN=RCSTA.4
#bit SREN=RCSTA.5
#bit RC89=RCSTA.6
#bit SPEN=RCSTA.7
//----- CCP2CON Bits ------------------------------------------------------
#bit CCP2M0=CCP2CON.0
#bit CCP2M1=CCP2CON.1
#bit CCP2M2=CCP2CON.2
#bit CCP2M3=CCP2CON.3
#bit CCP2Y=CCP2CON.4
#bit CCP2X=CCP2CON.5
//----- ADCON0 Bits -------------------------------------------------------
#bit ADON=ADCON0.0
#bit GO=ADCON0.2
#bit NOT_DONE=ADCON0.2
#bit DONE_=ADCON0.2
#bit CHS0=ADCON0.3
#bit CHS1=ADCON0.4
#bit CHS2=ADCON0.5
#bit ADCS0=ADCON0.6
#bit ADCS1=ADCON0.7
//----- OPTION_REG Bits -------------------------------------------------------
#bit PS0=OPTION_REG.0
#bit PS1=OPTION_REG.1
#bit PS2=OPTION_REG.2
#bit PSA=OPTION_REG.3
#bit T0SE=OPTION_REG.4
#bit RTE=OPTION_REG.4 // For compatibility
#bit T0CS=OPTION_REG.5
#bit RTS=OPTION_REG.5 // For compatibility
#bit INTEDG=OPTION_REG.6
#bit NOT_RBPU=OPTION_REG.7
#bit RBPU_=OPTION_REG.7
//----- PIE1 Bits ---------------------------------------------------------
#bit TMR1IE=PIE1.0
#bit TMR2IE=PIE1.1
#bit CCP1IE=PIE1.2
#bit SSPIE=PIE1.3
#bit TXIE=PIE1.4
#bit RCIE=PIE1.5
#bit ADIE=PIE1.6
#bit PSPIE=PIE1.7
//----- PIE2 Bits ---------------------------------------------------------
#bit CCP2IE=PIE2.0
//----- PCON Bits ---------------------------------------------------------
#bit NOT_POR=PCON.1
#bit POR=PCON.1 // For compatibility
#bit NOT_BOR=PCON.0
#bit BOR=PCON.0
//----- SSPSTAT Bits ------------------------------------------------------
#bit BF=SSPSTAT.0
#bit UA=SSPSTAT.1
#bit R=SSPSTAT.2
#bit R_W=SSPSTAT.2
#bit NOT_W=SSPSTAT.2
#bit W_=SSPSTAT.2
#bit I2C_START=SSPSTAT.3
#bit S=SSPSTAT.3
#bit P=SSPSTAT.4
#bit I2C_STOP=SSPSTAT.4
#bit D=SSPSTAT.5
#bit D_A=SSPSTAT.5
#bit NOT_A=SSPSTAT.5
#bit A_=SSPSTAT.5
#bit CKE=SSPSTAT.6
#bit SMP=SSPSTAT.7
//----- TXSTA Bits ---------------------------------------------------------
#bit TX9D=TXSTA.0
#bit TXD8=TXSTA.0
#bit TRMT=TXSTA.1
#bit BRGH=TXSTA.2
#bit SYNC=TXSTA.4
#bit TXEN=TXSTA.5
#bit TX89=TXSTA.6
#bit CSRC=TXSTA.7
//----- ADCON1 Bits -------------------------------------------------------
#bit PCFG0=ADCON1.0
#bit PCFG1=ADCON1.1
#bit PCFG2=ADCON1.2
#bit PCFG3=ADCON1.3
#bit ADFM=ADCON1.7
//----- EECON1 Bits -------------------------------------------------------
#bit RD=EECON1.0
#bit WR=EECON1.1
#bit WREN=EECON1.2
#bit WRERR=EECON1.3
#bit EEPGD=EECON1.7
/*
* Useful macros for CCS C compiler
* Written by Svetoslav Pirev, Nov-2000 - Dec-2005
*/
#define _NOP() #asm nop #endasm
#define _CLRWDT() #asm clrwdt #endasm
#define _MOVLW(value) #asm movlw value #endasm
#define _MOVWF(reg) #asm movwf reg #endasm
#define _ANDLW(value) #asm andlw value #endasm
#define _IORLW(value) #asm iorlw value #endasm
#define _RLF_F(data) #asm rlf data,F #endasm
#define _RLF_W(data) #asm rlf data,W #endasm
#define _RRF_F(data) #asm rrf data,F #endasm
#define _RRF_W(data) #asm rrf data,W #endasm
#define _COMF_F(data) #asm comf data,F #endasm
#define _COMF_W(data) #asm comf data,W #endasm
#define _HIGH(reg) #asm movf reg,W #endasm
#define _MOVF_W(reg) #asm movf reg,W #endasm
#define _MOVF_F(reg) #asm movf reg,F #endasm
#define _ADDWF_F(reg) #asm addwf reg,F #endasm
#define _ADDWF_W(reg) #asm addwf reg,W #endasm
#define _ANDWF_F(reg) #asm andwf reg,F #endasm
#define _ANDWF_W(reg) #asm andwf reg,W #endasm
#define _IORWF_F(reg) #asm iorwf reg,F #endasm
#define _IORWF_W(reg) #asm iorwf reg,W #endasm
#define _SWAPF_F(reg) #asm swapf reg,F #endasm
#define _SWAPF_W(reg) #asm swapf reg,W #endasm
#define _GETFSRF(reg) #asm movf INDF,W movwf reg #endasm
#define _SUBWF_W(reg) #asm subwf reg,W #endasm
#define _SUBWF_F(reg) #asm subwf reg,F #endasm
#define _DECF_F(reg) #asm decf reg,F #endasm
#define _DECF_W(reg) #asm decf reg,W #endasm
#define _INCF_F(reg) #asm incf reg,F #endasm
#define _INCF_W(reg) #asm incf reg,W #endasm
#list
|
PCM Programmer wrote: |
It looks like the problem is caused by a bug in vs. 3.245, because I
tested it with PCM vs. 3.249 and it works OK.
However, it looks like you can fix the problem with 3.245 by using
an #org statement to move the LedTable to another location in ROM.
Then the compiler puts the #int_global code at address 0x0004.
Code: |
#org 0x100, 0x12F
char const LedTable[szLedTable] = {
0x3F, 0x06, 0x5B, 0x4F, // characters 0,1,2 & 3
0x66, 0x6D, 0x7D, 0x07, // characters 4,5,6 & 7
0x7F, 0x6F, 0x77, 0x7C, // characters 8,9,A,B
0x39, 0x5E, 0x79, 0x71, // characters C,D,E,F
0x78, 0x76, 0x73, 0x38, // characters T,H,P,L
0x01, 0x41, 0x49, 0x00, // Upper line
0x1C, 0x54, 0x5C, 0x50, // 'u', 'n', 'o', 'r'
0x80
};
|
|
I will test above code, and it is work fine !
Thanks again. |
|
|
|
|
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
|