CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F87K22 ADC
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 11:03 am     Reply with quote

What compiler version?.

I remember there being an issue quite recently where one of the 12bit PIC's
went to 16bit mode if you tried to select 12bit mode....
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 11:43 am     Reply with quote

PCB,PCM,PCH,PCD V5.064

running on windows 10
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 11:54 am     Reply with quote

the reported number never changes for a voltage change on AN0. It is like it is locked up and sending junk.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 11:57 am     Reply with quote

What happens if you run a fairly simple program like this ? Try it.
Code:

#include <18F87K22.h>
#device ADC=12
#fuses INTRC_IO, NOWDT, PUT, NOBROWNOUT, NOMCLR
#use delay(crystal=10M, clock=40M)
#use rs232(UART1, baud=38400, STREAM=SERIAL, errors)

//==========================
void main()
{
int16 result;

delay_ms(100);

setup_adc(ADC_CLOCK_DIV_32);   
setup_adc_ports(sAN0 | VSS_VDD);     
set_adc_channel(0);
delay_us(5);

while(TRUE)
  {
   result = read_adc();
   fprintf(SERIAL, "%lx \n\r", result);
   delay_ms(500);
   output_toggle(PIN_B0);  // Blink LED at 1 Hz
  }
}   
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 12:23 pm     Reply with quote

I get around a 0297 HEX.
that comes out to 663 decimal and it responds to temperature change.

?????????????

Fuses?

could a fuse be messing with my INT_EXT as well? done an INT_EXT a million times and it is not working either.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 1:21 pm     Reply with quote

I have to go out for a few hours. Look at the .LST file. Look for differences.
If you don't find anything, I'll compare them when I get back.
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 2:06 pm     Reply with quote

here is my lst

    CCS PCH C Compiler, Version 5.064, 33349 25-Apr-19 15:03

    Filename: C:\18F87K22 CODE\MEMORY\MEMTEST.lst

    ROM used: 1982 bytes (2%)
    Largest free fragment is 65536
    RAM used: 610 (16%) at main() level
    628 (16%) worst case
    Stack used: 3 locations (2 in main + 1 for interrupts)
    Stack size: 30

    *
    00000: GOTO 054E
    *
    00008: MOVWF 04
    0000A: MOVFF FD8,05
    0000E: MOVFF FE0,06
    00012: MOVLB 0
    00014: MOVFF FE9,0C
    00018: MOVFF FEA,07
    0001C: MOVFF FE1,08
    00020: MOVFF FE2,09
    00024: MOVFF FD9,0A
    00028: MOVFF FDA,0B
    0002C: MOVFF FF3,12
    00030: MOVFF FF4,13
    00034: MOVFF FFA,14
    00038: MOVFF FF5,15
    0003C: MOVFF FF6,16
    00040: MOVFF FF7,17
    00044: MOVFF FF8,18
    00048: MOVFF FFB,19
    0004C: MOVFF 00,0E
    00050: MOVFF 01,0F
    00054: MOVFF 02,10
    00058: MOVFF 03,11
    0005C: BTFSS FF2.4
    0005E: GOTO 0068
    00062: BTFSC FF2.1
    00064: GOTO 00FC
    00068: BTFSS F9D.5
    0006A: GOTO 0074
    0006E: BTFSC F9E.5
    00070: GOTO 0148
    00074: MOVFF 0E,00
    00078: MOVFF 0F,01
    0007C: MOVFF 10,02
    00080: MOVFF 11,03
    00084: MOVFF 0C,FE9
    00088: MOVFF 07,FEA
    0008C: BSF 07.7
    0008E: MOVFF 08,FE1
    00092: MOVFF 09,FE2
    00096: MOVFF 0A,FD9
    0009A: MOVFF 0B,FDA
    0009E: MOVFF 12,FF3
    000A2: MOVFF 13,FF4
    000A6: MOVFF 14,FFA
    000AA: MOVFF 15,FF5
    000AE: MOVFF 16,FF6
    000B2: MOVFF 17,FF7
    000B6: MOVFF 18,FF8
    000BA: MOVFF 19,FFB
    000BE: MOVF 04,W
    000C0: MOVFF 06,FE0
    000C4: MOVFF 05,FD8
    000C8: RETFIE 0
    ....................
    ....................
    ....................
    .................... #DEVICE PIC18F87K22
    000CA: DATA 25,73
    000CC: DATA 20,0A
    000CE: DATA 0D,00
    000D0: TBLRD*+
    000D2: MOVF FF5,F
    000D4: BZ 00F8
    000D6: MOVFF FF6,271
    000DA: MOVFF FF7,272
    000DE: MOVFF FF8,273
    000E2: MOVF FF5,W
    000E4: BTFSS F9E.4
    000E6: BRA 00E4
    000E8: MOVWF FAD
    000EA: MOVFF 271,FF6
    000EE: MOVFF 272,FF7
    000F2: MOVFF 273,FF8
    000F6: BRA 00D0
    000F8: GOTO 010A (RETURN)
    *
    0011C: DATA 2A,2A
    0011E: DATA 2A,2A
    00120: DATA 2A,2A
    00122: DATA 20,44
    00124: DATA 45,47
    00126: DATA 20,46
    00128: DATA 3D,20
    0012A: DATA 20,23
    0012C: DATA 0A,0D
    0012E: DATA 00,00
    *
    0018E: DATA 2A,2A
    00190: DATA 20,44
    00192: DATA 45,47
    00194: DATA 20,46
    00196: DATA 3D,20
    00198: DATA 20,25
    0019A: DATA 6C,78
    0019C: DATA 23,0A
    0019E: DATA 0D,00
    001A0: DATA 2A,2A
    001A2: DATA 20,53
    001A4: DATA 52,41
    001A6: DATA 4D,3D
    001A8: DATA 20,20
    001AA: DATA 25,75
    001AC: DATA 23,0A
    001AE: DATA 0D,00
    *
    001EA: MOVF FEF,F
    001EC: BZ 020E
    001EE: MOVFF FEA,261
    001F2: MOVFF FE9,260
    001F6: MOVF FEF,W
    001F8: BTFSS F9E.4
    001FA: BRA 01F8
    001FC: MOVWF FAD
    001FE: MOVFF 261,FEA
    00202: MOVFF 260,FE9
    00206: INCF FE9,F
    00208: BTFSC FD8.2
    0020A: INCF FEA,F
    0020C: BRA 01EA
    0020E: GOTO 02A8 (RETURN)
    00212: TBLRD*+
    00214: MOVFF FF6,261
    00218: MOVFF FF7,262
    0021C: MOVFF FF8,263
    00220: MOVF FF5,W
    00222: BTFSS F9E.4
    00224: BRA 0222
    00226: MOVWF FAD
    00228: MOVFF 261,FF6
    0022C: MOVFF 262,FF7
    00230: MOVFF 263,FF8
    00234: MOVLB 2
    00236: DECFSZ x60,F
    00238: BRA 023C
    0023A: BRA 0240
    0023C: MOVLB 0
    0023E: BRA 0212
    00240: MOVLB 0
    00242: RETURN 0
    *
    00330: MOVLB 2
    00332: BTFSC x61.7
    00334: BRA 0356
    00336: MOVLW 0F
    00338: MOVWF 00
    0033A: SWAPF x60,W
    0033C: ANDWF 00,F
    0033E: MOVLW 0A
    00340: SUBWF 00,W
    00342: BC 034A
    00344: MOVLW 30
    00346: ADDWF 00,F
    00348: BRA 034E
    0034A: MOVF x61,W
    0034C: ADDWF 00,F
    0034E: MOVF 00,W
    00350: BTFSS F9E.4
    00352: BRA 0350
    00354: MOVWF FAD
    00356: MOVLW 0F
    00358: ANDWF x60,F
    0035A: MOVLW 0A
    0035C: SUBWF x60,W
    0035E: BC 0364
    00360: MOVLW 30
    00362: BRA 0368
    00364: BCF x61.7
    00366: MOVF x61,W
    00368: ADDWF x60,F
    0036A: MOVF x60,W
    0036C: BTFSS F9E.4
    0036E: BRA 036C
    00370: MOVWF FAD
    00372: MOVLB 0
    00374: RETURN 0
    *
    004A2: MOVLB 2
    004A4: MOVF x63,W
    004A6: CLRF 01
    004A8: SUBWF x62,W
    004AA: BC 04B2
    004AC: MOVFF 262,00
    004B0: BRA 04CA
    004B2: CLRF 00
    004B4: MOVLW 08
    004B6: MOVWF x64
    004B8: RLCF x62,F
    004BA: RLCF 00,F
    004BC: MOVF x63,W
    004BE: SUBWF 00,W
    004C0: BTFSC FD8.0
    004C2: MOVWF 00
    004C4: RLCF 01,F
    004C6: DECFSZ x64,F
    004C8: BRA 04B8
    004CA: MOVLB 0
    004CC: RETURN 0
    004CE: MOVF 01,W
    004D0: MOVFF 260,262
    004D4: MOVLW 64
    004D6: MOVLB 2
    004D8: MOVWF x63
    004DA: MOVLB 0
    004DC: RCALL 04A2
    004DE: MOVFF 00,260
    004E2: MOVF 01,W
    004E4: MOVLW 30
    004E6: BNZ 04F8
    004E8: MOVLB 2
    004EA: BTFSS x61.1
    004EC: BRA 050A
    004EE: BTFSC x61.3
    004F0: BRA 050A
    004F2: BTFSC x61.4
    004F4: MOVLW 20
    004F6: BRA 0500
    004F8: MOVLB 2
    004FA: BCF x61.3
    004FC: BCF x61.4
    004FE: BSF x61.0
    00500: ADDWF 01,F
    00502: MOVF 01,W
    00504: BTFSS F9E.4
    00506: BRA 0504
    00508: MOVWF FAD
    0050A: MOVFF 260,262
    0050E: MOVLW 0A
    00510: MOVWF x63
    00512: MOVLB 0
    00514: RCALL 04A2
    00516: MOVFF 00,260
    0051A: MOVF 01,W
    0051C: MOVLW 30
    0051E: BNZ 0530
    00520: MOVLB 2
    00522: BTFSC x61.3
    00524: BRA 053C
    00526: BTFSS x61.0
    00528: BRA 053C
    0052A: BTFSC x61.4
    0052C: MOVLW 20
    0052E: MOVLB 0
    00530: ADDWF 01,F
    00532: MOVF 01,W
    00534: BTFSS F9E.4
    00536: BRA 0534
    00538: MOVWF FAD
    0053A: MOVLB 2
    0053C: MOVLW 30
    0053E: ADDWF x60,F
    00540: MOVF x60,W
    00542: BTFSS F9E.4
    00544: BRA 0542
    00546: MOVWF FAD
    00548: MOVLB 0
    0054A: GOTO 07A2 (RETURN)
    ....................
    ....................
    .................... #include <18F87K22.h>
    .................... //////////// Standard Header file for the PIC18F87K22 device ////////////////
    .................... ///////////////////////////////////////////////////////////////////////////
    .................... //// (C) Copyright 1996, 2014 Custom Computer Services ////
    .................... //// This source code may only be used by licensed users of the CCS C ////
    .................... //// compiler. This source code may only be distributed to other ////
    .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
    .................... //// or distribution is permitted without written permission. ////
    .................... //// Derivative programs created using this software in object code ////
    .................... //// form are not restricted in any way. ////
    .................... ///////////////////////////////////////////////////////////////////////////
    .................... #device PIC18F87K22
    ....................
    .................... #list
    ....................
    .................... #DEVICE ADC=12
    .................... #fuses INTRC_IO, NOWDT, PUT, NOBROWNOUT, NOMCLR
    .................... //#include <stdlib.h>
    ....................
    ....................
    .................... #USE delay(CRYSTAL=10000000, CLOCK=40000000)
    *
    00306: MOVLW 02
    00308: MOVWF FEA
    0030A: MOVLW 61
    0030C: MOVWF FE9
    0030E: MOVF FEF,W
    00310: BZ 032E
    00312: MOVLW 0C
    00314: MOVWF 01
    00316: CLRF 00
    00318: DECFSZ 00,F
    0031A: BRA 0318
    0031C: DECFSZ 01,F
    0031E: BRA 0316
    00320: MOVLW F7
    00322: MOVWF 00
    00324: DECFSZ 00,F
    00326: BRA 0324
    00328: BRA 032A
    0032A: DECFSZ FEF,F
    0032C: BRA 0312
    0032E: RETURN 0
    .................... #USE rs232(UART1,baud=38400, xmit=PIN_C6,rcv=PIN_C7,STREAM=SERIAL,errors)
    *
    00130: BTFSS F9E.5
    00132: BRA 0130
    00134: MOVFF FAB,1B
    00138: MOVFF FAE,01
    0013C: BTFSS 1B.1
    0013E: BRA 0144
    00140: BCF FAB.4
    00142: BSF FAB.4
    00144: GOTO 014A (RETURN)
    .................... #USE SPI(MASTER, MODE=0, SPI1, STREAM=SPI,FORCE_HW)
    *
    00376: MOVF FC9,W
    00378: MOVFF 26C,FC9
    0037C: RRCF FC7,W
    0037E: BNC 037C
    00380: MOVFF FC9,00
    00384: RETURN 0
    00386: CLRF 03
    00388: MOVF FC9,W
    0038A: MOVFF 26D,FC9
    0038E: RRCF FC7,W
    00390: BNC 038E
    00392: MOVFF FC9,02
    00396: MOVF FC9,W
    00398: MOVFF 26C,FC9
    0039C: RRCF FC7,W
    0039E: BNC 039C
    003A0: MOVFF FC9,01
    003A4: MOVF FC9,W
    003A6: MOVFF 26B,FC9
    003AA: RRCF FC7,W
    003AC: BNC 03AA
    003AE: MOVFF FC9,00
    003B2: RETURN 0
    ....................
    ....................
    .................... /*
    .................... *********************************************************************************************
    .................... * DEFINES
    .................... *********************************************************************************************
    .................... */
    ....................
    ....................
    .................... #DEFINE LED_BLINK PIN_J5
    ....................
    ....................
    .................... /*
    .................... *********************************************************************************************
    .................... * PROTOTYPES
    .................... *********************************************************************************************
    .................... */
    ....................
    ....................
    .................... void SRAM_write_byte(unsigned int32, byte);
    .................... byte SRAM_read_byte(unsigned int32);
    .................... void SRAM_write_block(unsigned int32,byte,int16);
    .................... void SRAM_read_block(unsigned int32,byte,int16);
    .................... int read_temperature(void);
    .................... /*
    .................... *********************************************************************************************
    .................... * GLOBAL VARIABLES
    .................... *********************************************************************************************
    .................... */
    ....................
    .................... static int buffer_size = 19; // serial buffer size
    .................... static int buffer_index = 0; // serial buffer pointer
    .................... static char serial_buffer[20]; // serial buffer of chars.
    .................... static char response_buffer[30]; // response back to host confirming action requested.
    .................... static int msg_complete_flg = 0; // complete message received flag
    .................... static int trigger_status_flg = 0;
    ....................
    .................... int wr_data[256];
    .................... int rd_data[256];
    ....................
    .................... int deg_f=0;
    .................... int terminate_flg = 0; // Set to 1 when ACQ needs to reset
    .................... int arm_acq_flg = 0; // Set to 1 when ACQ needs to ARM to collect data.
    .................... /*
    .................... *********************************************************************************************
    .................... * CUSTOM INCLUDES
    .................... *********************************************************************************************
    .................... */
    .................... #include "23LC1024T.h" // SRAM drivers.
    ....................
    ....................
    .................... /* 23LC1024T Drivers 4-24-2019 Greg Shipley */
    ....................
    ....................
    ....................
    .................... /*
    .................... 23LC1024T PIN OUT:
    ....................
    .................... 1 -- CS 8 -- Vcc
    .................... 2 -- SO 7 -- HOLD
    .................... 3 -- NU 6 -- SCK
    .................... 4 -- Vss 5 -- SI
    .................... */
    ....................
    .................... #DEFINE SRAM_CS1 PIN_J2
    .................... #DEFINE SRAM_CS2 PIN_J3
    .................... #DEFINE SRAM_CS3 PIN_J6
    .................... #DEFINE EEPROM_CS PIN_B1
    .................... #DEFINE MODE_CMD 0x01
    .................... #DEFINE WRITE_CMD 0x02
    .................... #DEFINE READ_CMD 0x03
    .................... #DEFINE SRAM_HOLD PIN_j7
    .................... #DEFINE RDMR 0x05
    ....................
    .................... void SRAM_write_byte(unsigned int32 address, byte val)
    .................... {
    .................... // Write one byte to the 23LC1024 SRAM selected
    ....................
    .................... int8 dummy;
    ....................
    .................... output_low(SRAM_CS1); // test with chip 1
    .................... spi_xfer(SPI, WRITE_CMD, 8); // send write command
    .................... spi_xfer(SPI, address, 24); // send the address
    .................... dummy = spi_xfer(SPI, val, 8); // send byte and wait for it to send.
    .................... output_high(SRAM_CS1);
    ....................
    .................... } // end write_byte()
    ....................
    .................... byte SRAM_read_byte(unsigned int32 address)
    .................... {
    .................... // Read one byte from the 23LC1024 SRAM selected
    ....................
    .................... int8 rval;
    .................... output_low(SRAM_CS1);
    .................... spi_xfer(SPI, READ_CMD, 8); // send read command
    .................... spi_xfer(SPI, address, 24); // send address
    .................... rval=(spi_xfer(SPI, 0, 8)); // clock dummy to get reply
    .................... output_high(SRAM_CS1);
    .................... return rval;
    ....................
    .................... } // end read_byte()
    ....................
    ....................
    ....................
    .................... void SRAM_write_block(unsigned int32 address, byte *block, int16 number)
    .................... {
    .................... // send a block of data stored at 'block'
    .................... // number is how many items to send.
    .................... // commented out stuff is for 8000 word write time test.
    .................... int8 dummy;
    ....................
    .................... if(number<1) return; // do nothing if zero items requested to send.
    003B4: MOVLB 2
    003B6: MOVF x68,F
    003B8: BNZ 03C0
    003BA: MOVF x69,F
    003BC: BTFSC FD8.2
    003BE: BRA 0436
    ....................
    .................... output_low(SRAM_CS1); // test with chip 1
    003C0: BCF F9A.2
    003C2: BCF F91.2
    .................... spi_xfer(SPI, WRITE_CMD, 8); // send write command
    003C4: MOVLW 02
    003C6: MOVWF x6C
    003C8: MOVLB 0
    003CA: RCALL 0376
    .................... spi_xfer(SPI, address, 24); // send address
    003CC: MOVFF 265,26E
    003D0: MOVFF 264,26D
    003D4: MOVFF 263,26C
    003D8: MOVFF 262,26B
    003DC: RCALL 0386
    ....................
    .................... // Now, loop through the data
    .................... // for(i=0;i<64;i++) {
    .................... //num = number;
    .................... while(--number) // do except for the last byte
    003DE: MOVLB 2
    003E0: MOVF x68,W
    003E2: BTFSC FD8.2
    003E4: DECF x69,F
    003E6: DECF x68,F
    003E8: MOVF x68,W
    003EA: IORWF x69,W
    003EC: BZ 0410
    .................... {
    .................... // shift_test = 1234;
    .................... //value = shift_test<<8;
    ....................
    .................... dummy=*(block++);
    003EE: MOVFF 267,03
    003F2: MOVF x66,W
    003F4: INCF x66,F
    003F6: BTFSC FD8.2
    003F8: INCF x67,F
    003FA: MOVWF FE9
    003FC: MOVFF 03,FEA
    00400: MOVFF FEF,26A
    .................... spi_write(dummy);
    00404: MOVF FC9,W
    00406: MOVFF 26A,FC9
    0040A: RRCF FC7,W
    0040C: BNC 040A
    0040E: BRA 03E0
    ....................
    .................... } // end while loop for data send
    .................... //}
    .................... dummy=spi_xfer(SPI,*(block++),8); // send last byte
    00410: MOVFF 267,03
    00414: MOVF x66,W
    00416: INCF x66,F
    00418: BTFSC FD8.2
    0041A: INCF x67,F
    0041C: MOVWF FE9
    0041E: MOVFF 03,FEA
    00422: MOVFF FEF,26C
    00426: MOVLB 0
    00428: RCALL 0376
    0042A: MOVF 01,W
    0042C: MOVFF 00,26A
    .................... output_high(SRAM_CS1);
    00430: BCF F9A.2
    00432: BSF F91.2
    00434: MOVLB 2
    00436: MOVLB 0
    00438: GOTO 0734 (RETURN)
    ....................
    .................... } // end SRAM_write_block()
    ....................
    ....................
    .................... void SRAM_read_block(unsigned int32 address, byte *block, int16 number)
    .................... {
    ....................
    .................... // Read a block in from memeory
    .................... // number is how many bytes to retrieve
    ....................
    ....................
    .................... if(number<1) return; // do nothing if number is zero
    0043C: MOVLB 2
    0043E: MOVF x68,F
    00440: BNZ 0448
    00442: MOVF x69,F
    00444: BTFSC FD8.2
    00446: BRA 049C
    ....................
    .................... output_low(SRAM_CS1); // select chip
    00448: BCF F9A.2
    0044A: BCF F91.2
    ....................
    .................... spi_xfer(SPI, READ_CMD, 8); // send read command
    0044C: MOVLW 03
    0044E: MOVWF x6C
    00450: MOVLB 0
    00452: RCALL 0376
    .................... spi_xfer(SPI, address, 24); // send the start address
    00454: MOVFF 265,26E
    00458: MOVFF 264,26D
    0045C: MOVFF 263,26C
    00460: MOVFF 262,26B
    00464: RCALL 0386
    ....................
    .................... // Now loop through the data to read in.
    ....................
    .................... while(--number)
    00466: MOVLB 2
    00468: MOVF x68,W
    0046A: BTFSC FD8.2
    0046C: DECF x69,F
    0046E: DECF x68,F
    00470: MOVF x68,W
    00472: IORWF x69,W
    00474: BZ 0498
    .................... {
    .................... *(block++) = spi_xfer(SPI,0,8); // read bytes
    00476: MOVFF 267,03
    0047A: MOVF x66,W
    0047C: INCF x66,F
    0047E: BTFSC FD8.2
    00480: INCF x67,F
    00482: MOVWF FE9
    00484: MOVFF 03,FEA
    00488: CLRF x6C
    0048A: MOVLB 0
    0048C: RCALL 0376
    0048E: MOVF 01,W
    00490: MOVFF 00,FEF
    00494: BRA 0466
    00496: MOVLB 2
    .................... }
    ....................
    .................... output_high(SRAM_CS1); // chip select high
    00498: BCF F9A.2
    0049A: BSF F91.2
    0049C: MOVLB 0
    0049E: GOTO 0764 (RETURN)
    ....................
    .................... } // end SRAM_read_block()
    ....................
    .................... //#include "MCP9700T.h" // Temperature sensor drivers.
    .................... #include "SEISMIC_SERIAL.h"
    ....................
    ....................
    .................... // SEISMIC_SERIAL.h
    ....................
    .................... // 4-24-2019 Greg Shipley
    ....................
    ....................
    .................... // Necessary functions for serial communication between down hole Seismic ACQ module and up hole windows software.
    ....................
    ....................
    .................... void parse_message() {
    ....................
    ....................
    .................... // $T# Terminate sequence command, used to reset the controller back to the SEND_GREETING() function. All processes are stopped. 6-16-2012
    .................... // $ARM# sets the arm_acq_flg to 1 and readies the system for an ACQ period.
    ....................
    ....................
    .................... switch(serial_buffer[1])
    *
    001B0: MOVF 1F,W
    001B2: XORLW 54
    001B4: BZ 01BC
    001B6: XORLW 15
    001B8: BZ 01C6
    001BA: BRA 01E2
    .................... {
    ....................
    .................... case 'T': // Abort the control sequence
    .................... {
    .................... terminate_flg = 1; // 6-16-2012
    001BC: MOVLW 01
    001BE: MOVLB 2
    001C0: MOVWF x53
    ....................
    .................... break;
    001C2: BRA 01E4
    001C4: MOVLB 0
    .................... } // end case 'A' for abort sequence
    ....................
    ....................
    .................... case 'A': // Start button pressed on host panel.
    .................... {
    .................... if((serial_buffer[2] == 'R')&&(serial_buffer[3] == 'M')) { // message is 'ARM'
    001C6: MOVF 20,W
    001C8: SUBLW 52
    001CA: BNZ 01DC
    001CC: MOVF 21,W
    001CE: SUBLW 4D
    001D0: BNZ 01DC
    .................... arm_acq_flg = 1; // set the ARM flag for ACQ to get ready.
    001D2: MOVLW 01
    001D4: MOVLB 2
    001D6: MOVWF x54
    .................... }
    001D8: BRA 01E0
    001DA: MOVLB 0
    .................... else { // message was corrupt, blank it out reset the receive buffer
    ....................
    .................... arm_acq_flg = 0;
    001DC: MOVLB 2
    001DE: CLRF x54
    001E0: MOVLB 0
    ....................
    ....................
    .................... }
    ....................
    .................... } // end case 'S' Start button pressed on host panel.
    ....................
    ....................
    .................... default: // default case
    .................... {
    ....................
    .................... break; // end case default case
    001E2: MOVLB 2
    .................... }
    .................... } // end switch
    001E4: MOVLB 0
    001E6: GOTO 0622 (RETURN)
    ....................
    ....................
    .................... } // end parse message
    ....................
    .................... void respond_to_host() {
    .................... // This function sends a response back to the host proving the message was received and acted on.
    .................... // ** preceeds the message
    .................... // The message is sent from this function.
    .................... // 'ARMED' is sent when the arm_acq_flg is set to 1
    .................... // 'TRIGGERED' is sent when the trigger_status_flg is set to 1
    ....................
    .................... response_buffer[0] = '*';
    *
    00244: MOVLW 2A
    00246: MOVWF 32
    .................... response_buffer[1] = '*'; // ** tag on front of buffer for ID.
    00248: MOVWF 33
    ....................
    .................... if(arm_acq_flg == 1) { // send 'ARMED'
    0024A: MOVLB 2
    0024C: DECFSZ x54,W
    0024E: BRA 026E
    ....................
    .................... response_buffer[2] = 'A';
    00250: MOVLW 41
    00252: MOVWF 34
    .................... response_buffer[3] = 'R';
    00254: MOVLW 52
    00256: MOVWF 35
    .................... response_buffer[4] = 'M';
    00258: MOVLW 4D
    0025A: MOVWF 36
    .................... response_buffer[5] = 'E';
    0025C: MOVLW 45
    0025E: MOVWF 37
    .................... response_buffer[6] = 'D';
    00260: MOVLW 44
    00262: MOVWF 38
    .................... response_buffer[7] = '\n';
    00264: MOVLW 0A
    00266: MOVWF 39
    .................... response_buffer[8] = '\r';
    00268: MOVLW 0D
    0026A: MOVWF 3A
    .................... response_buffer[9] = '\0'; // end of string char
    0026C: CLRF 3B
    .................... }
    ....................
    .................... if(trigger_status_flg == 1) { // send 'TRIGGERED'
    0026E: DECFSZ 51,W
    00270: BRA 029E
    ....................
    .................... response_buffer[2] = 'T';
    00272: MOVLW 54
    00274: MOVWF 34
    .................... response_buffer[3] = 'R';
    00276: MOVLW 52
    00278: MOVWF 35
    .................... response_buffer[4] = 'I';
    0027A: MOVLW 49
    0027C: MOVWF 36
    .................... response_buffer[5] = 'G';
    0027E: MOVLW 47
    00280: MOVWF 37
    .................... response_buffer[6] = 'G';
    00282: MOVWF 38
    .................... response_buffer[7] = 'E';
    00284: MOVLW 45
    00286: MOVWF 39
    .................... response_buffer[8] = 'R';
    00288: MOVLW 52
    0028A: MOVWF 3A
    .................... response_buffer[9] = 'E';
    0028C: MOVLW 45
    0028E: MOVWF 3B
    .................... response_buffer[10] = 'D';
    00290: MOVLW 44
    00292: MOVWF 3C
    .................... response_buffer[11] = '\n';
    00294: MOVLW 0A
    00296: MOVWF 3D
    .................... response_buffer[12] = '\r';
    00298: MOVLW 0D
    0029A: MOVWF 3E
    .................... response_buffer[13] = '\0'; // end of string char
    0029C: CLRF 3F
    ....................
    .................... }
    .................... fprintf(SERIAL,"%s \n\r",response_buffer);
    0029E: CLRF FEA
    002A0: MOVLW 32
    002A2: MOVWF FE9
    002A4: MOVLB 0
    002A6: BRA 01EA
    002A8: MOVLW CC
    002AA: MOVWF FF6
    002AC: MOVLW 00
    002AE: MOVWF FF7
    002B0: MOVLW 00
    002B2: MOVWF FF8
    002B4: MOVLW 03
    002B6: MOVLB 2
    002B8: MOVWF x60
    002BA: MOVLB 0
    002BC: RCALL 0212
    002BE: RETURN 0
    .................... } // end respond_to_host()
    ....................
    .................... void clear_serial_buffer() {
    .................... // This function clears the serial buffer by assigning '\0' to all positions in the buffer
    ....................
    .................... int i;
    .................... for (i=0; i<buffer_size; i++) {
    002C0: MOVLB 2
    002C2: CLRF x60
    002C4: MOVF 1C,W
    002C6: SUBWF x60,W
    002C8: BC 02DE
    .................... serial_buffer[i] = '\0';
    002CA: CLRF 03
    002CC: MOVF x60,W
    002CE: ADDLW 1E
    002D0: MOVWF FE9
    002D2: MOVLW 00
    002D4: ADDWFC 03,W
    002D6: MOVWF FEA
    002D8: CLRF FEF
    002DA: INCF x60,F
    002DC: BRA 02C4
    .................... } // end for
    002DE: MOVLB 0
    002E0: GOTO 0628 (RETURN)
    .................... } // end clear_serial_buffer()
    ....................
    .................... void clear_response_buffer() {
    .................... // This function clears the response buffer by assigning '\0' to all positions in the buffer
    ....................
    .................... int i;
    .................... for (i=0; i<30; i++) {
    002E4: MOVLB 2
    002E6: CLRF x60
    002E8: MOVF x60,W
    002EA: SUBLW 1D
    002EC: BNC 0302
    .................... response_buffer[i] = '\0';
    002EE: CLRF 03
    002F0: MOVF x60,W
    002F2: ADDLW 32
    002F4: MOVWF FE9
    002F6: MOVLW 00
    002F8: ADDWFC 03,W
    002FA: MOVWF FEA
    002FC: CLRF FEF
    002FE: INCF x60,F
    00300: BRA 02E8
    .................... } // end for
    00302: MOVLB 0
    00304: RETURN 0
    .................... } // end clear_response_buffer()
    ....................
    ....................
    .................... #int_ext
    .................... void ext_isr() {
    .................... // isr to handle trigger line going from high to low on B0.
    .................... // if arm_acq_flg is set to 1 then acquisition starts.
    .................... // if arm_acq_flg is set to 0 then 'TRIGGERED' is sent to host by setting trigger_status_flg to 1
    .................... // to show that the hardware is working correctly.
    ....................
    .................... fprintf(SERIAL,"****** DEG F= #\n\r");
    *
    000FC: MOVLW 1C
    000FE: MOVWF FF6
    00100: MOVLW 01
    00102: MOVWF FF7
    00104: MOVLW 00
    00106: MOVWF FF8
    00108: BRA 00D0
    .................... if(arm_acq_flg == 1) {
    0010A: MOVLB 2
    0010C: DECFSZ x54,W
    0010E: BRA 0110
    ....................
    .................... // test ACQ to start taking seismic data
    ....................
    .................... }
    ....................
    .................... //if(arm_acq_flg == 0) { // just let host know ACQ saw the trigger line go low
    ....................
    .................... trigger_status_flg = 1;
    00110: MOVLW 01
    00112: MOVWF 51
    ....................
    .................... //}
    ....................
    .................... } // end ext_isr
    ....................
    00114: BCF FF2.1
    00116: MOVLB 0
    00118: GOTO 0074
    .................... #int_rda
    .................... void serial_isr() {
    .................... // Reads incoming data from the USART and puts it in a buffer
    ....................
    .................... char cChar;
    .................... cChar = fgetc(SERIAL);
    *
    00148: BRA 0130
    0014A: MOVFF 01,271
    .................... serial_buffer[buffer_index] = cChar; // put the char in the buffer.
    0014E: CLRF 03
    00150: MOVF 1D,W
    00152: ADDLW 1E
    00154: MOVWF FE9
    00156: MOVLW 00
    00158: ADDWFC 03,W
    0015A: MOVWF FEA
    0015C: MOVFF 271,FEF
    .................... buffer_index = buffer_index + 1; // index to next buffer location.
    00160: MOVLW 01
    00162: ADDWF 1D,F
    .................... if(cChar == '#') { // The message is complete.
    00164: MOVLB 2
    00166: MOVF x71,W
    00168: SUBLW 23
    0016A: BNZ 0184
    .................... msg_complete_flg = 1;
    0016C: MOVLW 01
    0016E: MOVWF 50
    .................... serial_buffer[buffer_index] = '\0'; // end of string char
    00170: CLRF 03
    00172: MOVF 1D,W
    00174: ADDLW 1E
    00176: MOVWF FE9
    00178: MOVLW 00
    0017A: ADDWFC 03,W
    0017C: MOVWF FEA
    0017E: CLRF FEF
    .................... buffer_index = 0; // reset buffer index to zero for next message.
    00180: CLRF 1D
    .................... } // end if
    00182: BRA 0186
    .................... else {
    .................... msg_complete_flg = 0;
    00184: CLRF 50
    .................... } // end else
    00186: BCF F9E.5
    00188: MOVLB 0
    0018A: GOTO 0074
    .................... } // end serial_isr()
    ....................
    .................... void init_hardware() {
    .................... // Initializes all hardware.
    ....................
    .................... output_high(SRAM_CS1);
    .................... output_high(SRAM_CS2);
    .................... output_high(SRAM_CS3); // SRAM and EEPROM Select lines
    .................... output_high(EEPROM_CS);
    ....................
    .................... output_low(LED_BLINK);
    .................... output_high(SRAM_HOLD);
    .................... setup_adc(ADC_CLOCK_DIV_32); // set up ADC
    .................... setup_adc_ports(sAN0|VSS_VDD); // only AN0 is analog port with range of 0 - 5VDC
    ....................
    .................... ext_int_edge(H_TO_L); // init interrupt triggering for button press
    .................... enable_interrupts(INT_EXT);// turn on interrupts
    .................... enable_interrupts(GLOBAL);
    .................... /* enable_interrupts(INT_RDA); // set up the serial interrupt
    .................... // enable_interrupts(INT_EXT|INT_EXT_H2L );
    .................... //clear_interrupt(INT_EXT); // prevent INT_EXT to fire on reset
    .................... ext_int_edge(0,H_TO_L); // init interrupt triggering for INT_EXT
    .................... enable_interrupts(GLOBAL); // turn on interrupts.
    .................... enable_interrupts(INT_EXT|INT_EXT_H2L );*/
    ....................
    .................... } // end init_hardware()
    ....................
    ....................
    .................... void main() {
    *
    0054E: CLRF FF8
    00550: BCF FD0.7
    00552: BSF 07.7
    00554: CLRF 1B
    00556: BCF F65.3
    00558: MOVLW 40
    0055A: MOVWF FAF
    0055C: MOVLW A6
    0055E: MOVWF FAC
    00560: MOVLW 90
    00562: MOVWF FAB
    00564: BCF FC6.5
    00566: MOVLW 40
    00568: MOVWF FC7
    0056A: MOVLW 20
    0056C: MOVWF FC6
    0056E: BCF F94.5
    00570: BSF F94.4
    00572: BCF F94.3
    00574: MOVLW 13
    00576: MOVWF 1C
    00578: CLRF 1D
    0057A: CLRF 50
    0057C: CLRF 51
    0057E: MOVLB 2
    00580: CLRF x52
    00582: CLRF x53
    00584: CLRF x54
    00586: CLRF x56
    00588: CLRF x55
    0058A: MOVLW 00
    0058C: MOVLB F
    0058E: MOVWF x23
    00590: MOVWF x24
    00592: MOVWF x25
    00594: BCF FC1.3
    00596: BCF FC1.4
    00598: BCF FC1.5
    0059A: CLRF x2E
    0059C: CLRF x2F
    0059E: CLRF x54
    005A0: BRA 05A8
    005A2: DATA 32,40
    005A4: DATA 1E,00
    005A6: DATA 00,00
    005A8: MOVLW 00
    005AA: MOVWF FF8
    005AC: MOVLW 05
    005AE: MOVWF FF7
    005B0: MOVLW A2
    005B2: MOVWF FF6
    005B4: TBLRD*+
    005B6: MOVF FF5,W
    005B8: MOVWF 00
    005BA: XORLW 00
    005BC: BZ 05E4
    005BE: TBLRD*+
    005C0: MOVF FF5,W
    005C2: MOVWF 01
    005C4: BTFSC FE8.7
    005C6: BRA 05D2
    005C8: ANDLW 0F
    005CA: MOVWF FEA
    005CC: TBLRD*+
    005CE: MOVFF FF5,FE9
    005D2: BTFSC 01.6
    005D4: TBLRD*+
    005D6: BTFSS 01.6
    005D8: TBLRD*+
    005DA: MOVFF FF5,FEE
    005DE: DCFSNZ 00,F
    005E0: BRA 05B4
    005E2: BRA 05D6
    005E4: CLRF FF8
    005E6: MOVLB 2
    005E8: CLRF x57
    005EA: CLRF x59
    ....................
    .................... // one SRAM holds 1Mb of data.
    ....................
    ....................
    ....................
    ....................
    .................... byte rval = 0;
    .................... int i;
    .................... int LED_toggle=0;
    ....................
    ....................
    .................... for(i=0;i<250;i++) {
    005EC: CLRF x58
    005EE: MOVF x58,W
    005F0: SUBLW F9
    005F2: BNC 061A
    ....................
    .................... wr_data[i] = i;
    005F4: CLRF 03
    005F6: MOVF x58,W
    005F8: ADDLW 52
    005FA: MOVWF FE9
    005FC: MOVLW 00
    005FE: ADDWFC 03,W
    00600: MOVWF FEA
    00602: MOVFF 258,FEF
    .................... rd_data[i] = 0; // load up the arrays.
    00606: CLRF 03
    00608: MOVF x58,W
    0060A: ADDLW 52
    0060C: MOVWF FE9
    0060E: MOVLW 01
    00610: ADDWFC 03,W
    00612: MOVWF FEA
    00614: CLRF FEF
    00616: INCF x58,F
    00618: BRA 05EE
    .................... }
    ....................
    ....................
    .................... while(1) {
    ....................
    ....................
    .................... if(msg_complete_flg == 1) {
    0061A: DECFSZ 50,W
    0061C: BRA 062E
    ....................
    .................... parse_message(); // parse out incomming message
    0061E: MOVLB 0
    00620: BRA 01B0
    .................... respond_to_host();
    00622: RCALL 0244
    .................... msg_complete_flg = 0;
    00624: CLRF 50
    .................... clear_serial_buffer();
    00626: BRA 02C0
    .................... clear_response_buffer();
    00628: RCALL 02E4
    .................... msg_complete_flg = 0;
    0062A: CLRF 50
    0062C: MOVLB 2
    .................... }
    ....................
    .................... if(trigger_status_flg == 1) { // send 'TRIGGERED' to the host.
    0062E: DECFSZ 51,W
    00630: BRA 063C
    ....................
    .................... respond_to_host();
    00632: MOVLB 0
    00634: RCALL 0244
    .................... trigger_status_flg = 0;
    00636: CLRF 51
    .................... clear_response_buffer();
    00638: RCALL 02E4
    0063A: MOVLB 2
    ....................
    .................... }
    ....................
    .................... //deg_F = read_temperature();
    ....................
    .................... int32 value = 0;
    .................... int16 adc_value = 0;
    0063C: CLRF x5D
    0063E: CLRF x5C
    00640: CLRF x5B
    00642: CLRF x5A
    00644: CLRF x5F
    00646: CLRF x5E
    ....................
    .................... set_adc_channel(0);
    00648: MOVLW 00
    0064A: MOVWF 01
    0064C: MOVF FC2,W
    0064E: ANDLW 83
    00650: IORWF 01,W
    00652: MOVWF FC2
    00654: MOVLW 00
    00656: MOVWF 01
    00658: MOVF FC1,W
    0065A: ANDLW F8
    0065C: IORWF 01,W
    0065E: MOVWF FC1
    .................... delay_ms(50);
    00660: MOVLW 32
    00662: MOVWF x61
    00664: MOVLB 0
    00666: RCALL 0306
    .................... adc_value = read_adc();
    00668: BSF FC2.1
    0066A: BTFSC FC2.1
    0066C: BRA 066A
    0066E: MOVFF FC4,25F
    00672: MOVLB 2
    00674: MOVFF FC3,25E
    ....................
    .................... //value = (int)(((adc_value/4096.0)*5.0)/0.01); // convert ADC to degrees F cast to INT to save space only need INT precision
    .................... //adc_value = adc_value/4096;
    .................... //adc_value = adc_value*5;
    .................... //adc_value = adc_value*100;
    .................... //value = ((int32)adc_value*500)/4096;
    .................... //value = (int)adc_value;
    .................... //return value;
    ....................
    .................... fprintf(SERIAL,"** DEG F= %lx#\n\r",adc_value);
    00678: MOVLW 8E
    0067A: MOVWF FF6
    0067C: MOVLW 01
    0067E: MOVWF FF7
    00680: MOVLW 00
    00682: MOVWF FF8
    00684: MOVLW 0B
    00686: MOVWF x60
    00688: MOVLB 0
    0068A: RCALL 0212
    0068C: MOVFF 25F,260
    00690: MOVLW 57
    00692: MOVLB 2
    00694: MOVWF x61
    00696: MOVLB 0
    00698: RCALL 0330
    0069A: MOVFF 25E,260
    0069E: MOVLW 57
    006A0: MOVLB 2
    006A2: MOVWF x61
    006A4: MOVLB 0
    006A6: RCALL 0330
    006A8: MOVLW 9C
    006AA: MOVWF FF6
    006AC: MOVLW 01
    006AE: MOVWF FF7
    006B0: MOVLW 00
    006B2: MOVWF FF8
    006B4: MOVLW 03
    006B6: MOVLB 2
    006B8: MOVWF x60
    006BA: MOVLB 0
    006BC: RCALL 0212
    ....................
    .................... delay_ms(1000);
    006BE: MOVLW 04
    006C0: MOVLB 2
    006C2: MOVWF x60
    006C4: MOVLW FA
    006C6: MOVWF x61
    006C8: MOVLB 0
    006CA: RCALL 0306
    006CC: MOVLB 2
    006CE: DECFSZ x60,F
    006D0: BRA 06C4
    .................... delay_ms(1000);
    006D2: MOVLW 04
    006D4: MOVWF x60
    006D6: MOVLW FA
    006D8: MOVWF x61
    006DA: MOVLB 0
    006DC: RCALL 0306
    006DE: MOVLB 2
    006E0: DECFSZ x60,F
    006E2: BRA 06D6
    .................... delay_ms(1000);
    006E4: MOVLW 04
    006E6: MOVWF x60
    006E8: MOVLW FA
    006EA: MOVWF x61
    006EC: MOVLB 0
    006EE: RCALL 0306
    006F0: MOVLB 2
    006F2: DECFSZ x60,F
    006F4: BRA 06E8
    .................... delay_ms(1000);
    006F6: MOVLW 04
    006F8: MOVWF x60
    006FA: MOVLW FA
    006FC: MOVWF x61
    006FE: MOVLB 0
    00700: RCALL 0306
    00702: MOVLB 2
    00704: DECFSZ x60,F
    00706: BRA 06FA
    ....................
    .................... if(LED_toggle == 0) {
    00708: MOVF x59,F
    0070A: BNZ 0716
    ....................
    .................... output_high(LED_BLINK);
    0070C: BCF F9A.5
    0070E: BSF F91.5
    .................... LED_toggle = 1;
    00710: MOVLW 01
    00712: MOVWF x59
    .................... }
    00714: BRA 071C
    .................... else {
    ....................
    .................... output_low(LED_BLINK);
    00716: BCF F9A.5
    00718: BCF F91.5
    .................... LED_toggle = 0;
    0071A: CLRF x59
    ....................
    .................... }
    ....................
    ....................
    ....................
    .................... SRAM_write_block(0L,&wr_data,250);
    0071C: CLRF x65
    0071E: CLRF x64
    00720: CLRF x63
    00722: CLRF x62
    00724: CLRF x67
    00726: MOVLW 52
    00728: MOVWF x66
    0072A: CLRF x69
    0072C: MOVLW FA
    0072E: MOVWF x68
    00730: MOVLB 0
    00732: BRA 03B4
    ....................
    .................... if(LED_toggle == 0) {
    00734: MOVLB 2
    00736: MOVF x59,F
    00738: BNZ 0744
    ....................
    .................... output_high(LED_BLINK);
    0073A: BCF F9A.5
    0073C: BSF F91.5
    .................... LED_toggle = 1;
    0073E: MOVLW 01
    00740: MOVWF x59
    .................... }
    00742: BRA 074A
    .................... else {
    ....................
    .................... output_low(LED_BLINK);
    00744: BCF F9A.5
    00746: BCF F91.5
    .................... LED_toggle = 0;
    00748: CLRF x59
    ....................
    .................... }
    .................... SRAM_read_block(0L,&rd_data,251);
    0074A: CLRF x65
    0074C: CLRF x64
    0074E: CLRF x63
    00750: CLRF x62
    00752: MOVLW 01
    00754: MOVWF x67
    00756: MOVLW 52
    00758: MOVWF x66
    0075A: CLRF x69
    0075C: MOVLW FB
    0075E: MOVWF x68
    00760: MOVLB 0
    00762: BRA 043C
    ....................
    .................... for(i=0;i<250;i++) {
    00764: MOVLB 2
    00766: CLRF x58
    00768: MOVF x58,W
    0076A: SUBLW F9
    0076C: BNC 07BE
    ....................
    .................... rval = rd_data[i];
    0076E: CLRF 03
    00770: MOVF x58,W
    00772: ADDLW 52
    00774: MOVWF FE9
    00776: MOVLW 01
    00778: ADDWFC 03,W
    0077A: MOVWF FEA
    0077C: MOVFF FEF,257
    .................... fprintf(SERIAL,"** SRAM= %u#\n\r",rval);
    00780: MOVLW A0
    00782: MOVWF FF6
    00784: MOVLW 01
    00786: MOVWF FF7
    00788: MOVLW 00
    0078A: MOVWF FF8
    0078C: MOVLW 0A
    0078E: MOVWF x60
    00790: MOVLB 0
    00792: RCALL 0212
    00794: MOVFF 257,260
    00798: MOVLW 1B
    0079A: MOVLB 2
    0079C: MOVWF x61
    0079E: MOVLB 0
    007A0: BRA 04CE
    007A2: MOVLW AC
    007A4: MOVWF FF6
    007A6: MOVLW 01
    007A8: MOVWF FF7
    007AA: MOVLW 00
    007AC: MOVWF FF8
    007AE: MOVLW 03
    007B0: MOVLB 2
    007B2: MOVWF x60
    007B4: MOVLB 0
    007B6: RCALL 0212
    007B8: MOVLB 2
    007BA: INCF x58,F
    007BC: BRA 0768
    .................... }
    007BE: BRA 061A
    ....................
    .................... } // end endless loop
    ....................
    .................... } // end main
    ....................
    007C0: BRA 07C0

    Configuration Fuses:
    Word 1: D315 VREGSLEEP INTRC_HP SOSC_DIG NOXINST HSM PLLEN FCMEN IESO
    Word 2: 7C79 NOPUT NOBROWNOUT BORV18 ZPBORM NOWDT WDT1048576
    Word 3: 0BF9 RTCOSC_T1 EXTADDRSFT ABW8 BW16 NOWAIT CCP2C1 ECCPE MSSPMSK7 NOMCLR
    Word 4: 0011 STVREN BBSIZ2K DEBUG
    Word 5: C0FF NOPROTECT NOCPB NOCPD
    Word 6: E0FF NOWRT NOWRTC NOWRTB NOWRTD
    Word 7: 40FF NOEBTR NOEBTRB

    Some fuses have been forced to be compatible with the ICD debugger.



and here is the small program that works

    CCS PCH C Compiler, Version 5.064, 33349 25-Apr-19 14:41

    Filename: C:\18F87K22 CODE\MEMORY\MEMTEST.lst

    ROM used: 348 bytes (0%)
    Largest free fragment is 65536
    RAM used: 8 (0%) at main() level
    11 (0%) worst case
    Stack used: 0 locations
    Stack size: 30

    *
    00000: GOTO 00A0
    ....................
    ....................
    .................... #device PIC18f87k22
    00004: DATA 25,6C
    00006: DATA 78,20
    00008: DATA 0A,0D
    0000A: DATA 00,00
    *
    00034: BTFSC 08.7
    00036: BRA 0058
    00038: MOVLW 0F
    0003A: MOVWF 00
    0003C: SWAPF 07,W
    0003E: ANDWF 00,F
    00040: MOVLW 0A
    00042: SUBWF 00,W
    00044: BC 004C
    00046: MOVLW 30
    00048: ADDWF 00,F
    0004A: BRA 0050
    0004C: MOVF 08,W
    0004E: ADDWF 00,F
    00050: MOVF 00,W
    00052: BTFSS F9E.4
    00054: BRA 0052
    00056: MOVWF FAD
    00058: MOVLW 0F
    0005A: ANDWF 07,F
    0005C: MOVLW 0A
    0005E: SUBWF 07,W
    00060: BC 0066
    00062: MOVLW 30
    00064: BRA 006A
    00066: BCF 08.7
    00068: MOVF 08,W
    0006A: ADDWF 07,F
    0006C: MOVF 07,W
    0006E: BTFSS F9E.4
    00070: BRA 006E
    00072: MOVWF FAD
    00074: RETURN 0
    00076: TBLRD*+
    00078: MOVFF FF6,08
    0007C: MOVFF FF7,09
    00080: MOVFF FF8,0A
    00084: MOVF FF5,W
    00086: BTFSS F9E.4
    00088: BRA 0086
    0008A: MOVWF FAD
    0008C: MOVFF 08,FF6
    00090: MOVFF 09,FF7
    00094: MOVFF 0A,FF8
    00098: DECFSZ 07,F
    0009A: BRA 0076
    0009C: GOTO 0148 (RETURN)
    .................... #include <18F87K22.h>
    .................... //////////// Standard Header file for the PIC18F87K22 device ////////////////
    .................... ///////////////////////////////////////////////////////////////////////////
    .................... //// (C) Copyright 1996, 2014 Custom Computer Services ////
    .................... //// This source code may only be used by licensed users of the CCS C ////
    .................... //// compiler. This source code may only be distributed to other ////
    .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
    .................... //// or distribution is permitted without written permission. ////
    .................... //// Derivative programs created using this software in object code ////
    .................... //// form are not restricted in any way. ////
    .................... ///////////////////////////////////////////////////////////////////////////
    .................... #device PIC18F87K22
    ....................
    .................... #list
    ....................
    .................... #device ADC=12
    .................... #fuses INTRC_IO, NOWDT, PUT, NOBROWNOUT, NOMCLR
    .................... #use delay(crystal=10M, clock=40M)
    *
    0000C: CLRF FEA
    0000E: MOVLW 08
    00010: MOVWF FE9
    00012: MOVF FEF,W
    00014: BZ 0032
    00016: MOVLW 0C
    00018: MOVWF 01
    0001A: CLRF 00
    0001C: DECFSZ 00,F
    0001E: BRA 001C
    00020: DECFSZ 01,F
    00022: BRA 001A
    00024: MOVLW F7
    00026: MOVWF 00
    00028: DECFSZ 00,F
    0002A: BRA 0028
    0002C: BRA 002E
    0002E: DECFSZ FEF,F
    00030: BRA 0016
    00032: RETURN 0
    .................... #use rs232(UART1, baud=38400, STREAM=SERIAL, errors)
    ....................
    .................... //==========================
    .................... void main()
    *
    000A0: CLRF FF8
    000A2: BCF FD0.7
    000A4: CLRF 04
    000A6: BCF F65.3
    000A8: MOVLW 40
    000AA: MOVWF FAF
    000AC: MOVLW A6
    000AE: MOVWF FAC
    000B0: MOVLW 90
    000B2: MOVWF FAB
    000B4: MOVLW 00
    000B6: MOVLB F
    000B8: MOVWF x23
    000BA: MOVWF x24
    000BC: MOVWF x25
    000BE: BCF FC1.3
    000C0: BCF FC1.4
    000C2: BCF FC1.5
    000C4: CLRF x2E
    000C6: CLRF x2F
    000C8: CLRF x54
    .................... {
    .................... int16 result;
    ....................
    .................... delay_ms(100);
    000CA: MOVLW 64
    000CC: MOVWF 08
    000CE: MOVLB 0
    000D0: RCALL 000C
    ....................
    .................... setup_adc(ADC_CLOCK_DIV_32);
    000D2: MOVF FC0,W
    000D4: ANDLW C0
    000D6: IORLW 02
    000D8: MOVWF FC0
    000DA: BSF FC0.7
    000DC: BSF FC2.0
    .................... setup_adc_ports(sAN0 | VSS_VDD);
    000DE: MOVLW 00
    000E0: MOVLB F
    000E2: MOVWF x23
    000E4: MOVWF x24
    000E6: MOVLW 01
    000E8: MOVWF x25
    000EA: BCF FC1.3
    000EC: BCF FC1.4
    000EE: BCF FC1.5
    .................... set_adc_channel(0);
    000F0: MOVLW 00
    000F2: MOVWF 01
    000F4: MOVF FC2,W
    000F6: ANDLW 83
    000F8: IORWF 01,W
    000FA: MOVWF FC2
    000FC: MOVLW 00
    000FE: MOVWF 01
    00100: MOVF FC1,W
    00102: ANDLW F8
    00104: IORWF 01,W
    00106: MOVWF FC1
    .................... delay_us(5);
    00108: MOVLW 10
    0010A: MOVWF 00
    0010C: DECFSZ 00,F
    0010E: BRA 010C
    00110: NOP
    ....................
    .................... while(TRUE)
    .................... {
    .................... result = read_adc();
    00112: BSF FC2.1
    00114: BTFSC FC2.1
    00116: BRA 0114
    00118: MOVFF FC3,05
    0011C: MOVFF FC4,06
    .................... fprintf(SERIAL, "%lx \n\r", result);
    00120: MOVFF 06,07
    00124: MOVLW 57
    00126: MOVWF 08
    00128: MOVLB 0
    0012A: RCALL 0034
    0012C: MOVFF 05,07
    00130: MOVLW 57
    00132: MOVWF 08
    00134: RCALL 0034
    00136: MOVLW 07
    00138: MOVWF FF6
    0013A: MOVLW 00
    0013C: MOVWF FF7
    0013E: MOVLW 00
    00140: MOVWF FF8
    00142: MOVLW 03
    00144: MOVWF 07
    00146: BRA 0076
    .................... delay_ms(500);
    00148: MOVLW 02
    0014A: MOVWF 07
    0014C: MOVLW FA
    0014E: MOVWF 08
    00150: RCALL 000C
    00152: DECFSZ 07,F
    00154: BRA 014C
    00156: MOVLB F
    00158: BRA 0112
    .................... //output_toggle(PIN_B0); // Blink LED at 1 Hz
    .................... }
    .................... }
    0015A: BRA 015A

    Configuration Fuses:
    Word 1: D315 VREGSLEEP INTRC_HP SOSC_DIG NOXINST HSM PLLEN FCMEN IESO
    Word 2: 7C79 NOPUT NOBROWNOUT BORV18 ZPBORM NOWDT WDT1048576
    Word 3: 0BF9 RTCOSC_T1 EXTADDRSFT ABW8 BW16 NOWAIT CCP2C1 ECCPE MSSPMSK7 NOMCLR
    Word 4: 0011 STVREN BBSIZ2K DEBUG
    Word 5: C0FF NOPROTECT NOCPB NOCPD
    Word 6: E0FF NOWRT NOWRTC NOWRTB NOWRTD
    Word 7: 40FF NOEBTR NOEBTRB

    Some fuses have been forced to be compatible with the ICD debugger.
[/list]
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 2:55 pm     Reply with quote

OK, so I scrolled through your listing ,a couple of times and some glaring problems...

The one BIG one is printing inside an ISR. That is a BIG 'nono' ! ISR MUST be small, compact and FAST. All prints are sloooooooow and need to be avoided within all ISRs.

You NEED to run PCM P's test program NOT your code. it's too full of things that can cause problems. You must minimize code to JUST 'read the ADC,print,delay, doitall again'. The raw data from the temperature sensor should be +-1 or 3 bits.

There is a lot of potential hardware problems. Long ,noisy wires from sensor to ADC, Noisy Vref,I see you're using VDD AS Vref...bad,bad,bad. While you can get away with it for an 8 bit ADC, you NEED a precision, stable source for Vref for 10,12,16 bit ADCs. Proper attention to bypass caps, PCB layout, etc. Analog can be quite 'challenging' to get right. 2/3 of my lifetime ago, I designed 32 channel, 16 bit mass spectrometer data acquistion systems...so I'm familiar with ADCs and noise. Best I could get was +-3 bits.

Jay
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 3:04 pm     Reply with quote

something definitely going on here, patched in my INT_EXT code into the small test program that the ADC works in, and it works too!!! INT_EXT does not work in the original .C file that is having the ADC problems today.

corrupt file? we use onedrive here and it always wants to make MPLAB reload a version of a file randomly.

If the file is corrupt. how is the best way to recover/ keep this from happening? I have cut and pasted into a blank file, and it still does not work.

I sure hope PCM is able to find something in the LST files that is preventable and my error and not a corrupted file from who knows what.

I await the findings.
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Thu Apr 25, 2019 4:14 pm     Reply with quote

well, may never know what really happened here.
I noticed that the .C file in my MPLAB project was being taken from our ONEDRIVE not my local folder that had the rest of my project in it.
This particular file was very out of date and did not call my init_hardware routine.
so, I made sure the local .C file was being opened and cut and paste starting with PCM's basic ADC program. rebuilt the rest of the file to include all of my code, testing at each step. two hours later, it all works. ADC, INT_EXT and INT_RDA now I am back where I was 11 hours ago and do not know how this happened or what really to do to keep it from happening again. I did pause the sync of ONEDRIVE for 24 hrs.

Comments? PCM, will be interested if you see anything in the LST files besides the init_hardware not being called in the version I posted.

perplexed to say the least.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 26, 2019 1:44 am     Reply with quote

How about using ExamDiff to compare the two versions of source code ?

To find the differences between your new code and your old code:

1. Download ExamDiff from: https://www.prestosoft.com/edp_examdiff.asp
2. Run Examdiff and select those two files to compare.
3. Examdiff will load both and show differences highlighted in yellow.
You can go to the View menu and have it show differences only, if you want.

Look at the differences and locate the lines causing the problem.
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Fri Apr 26, 2019 6:36 am     Reply with quote

our IT will not allow software like that. is there an online version for comparing?
beaker404



Joined: 24 Jul 2012
Posts: 163

View user's profile Send private message

PostPosted: Fri Apr 26, 2019 6:49 am     Reply with quote

found and ran diffnow. powered by examdiff.
lots of differences but one that stands out to me at least is
the first line in the file that does not work is

0000: GOTO 0568

and the first line in the file that does work is

0000: GOTO 00A0

the one that does not work has the following assembler that is prior to any instruction:
Code:
00000:  GOTO   0568
*
00008:  MOVWF  04
0000A:  MOVFF  FD8,05
0000E:  MOVFF  FE0,06
00012:  MOVLB  0
00014:  MOVFF  FE9,0C
00018:  MOVFF  FEA,07
0001C:  MOVFF  FE1,08
00020:  MOVFF  FE2,09
00024:  MOVFF  FD9,0A
00028:  MOVFF  FDA,0B
0002C:  MOVFF  FF3,12
00030:  MOVFF  FF4,13
00034:  MOVFF  FFA,14
00038:  MOVFF  FF5,15
0003C:  MOVFF  FF6,16
00040:  MOVFF  FF7,17
00044:  MOVFF  FF8,18
00048:  MOVFF  FFB,19
0004C:  MOVFF  00,0E
00050:  MOVFF  01,0F
00054:  MOVFF  02,10
00058:  MOVFF  03,11
0005C:  BTFSS  FF2.4
0005E:  GOTO   0068
00062:  BTFSC  FF2.1
00064:  GOTO   00FA
00068:  BTFSS  F9D.5
0006A:  GOTO   0074
0006E:  BTFSC  F9E.5
00070:  GOTO   0144
00074:  MOVFF  0E,00
00078:  MOVFF  0F,01
0007C:  MOVFF  10,02
00080:  MOVFF  11,03
00084:  MOVFF  0C,FE9
00088:  MOVFF  07,FEA
0008C:  BSF    07.7
0008E:  MOVFF  08,FE1
00092:  MOVFF  09,FE2
00096:  MOVFF  0A,FD9
0009A:  MOVFF  0B,FDA
0009E:  MOVFF  12,FF3
000A2:  MOVFF  13,FF4
000A6:  MOVFF  14,FFA
000AA:  MOVFF  15,FF5
000AE:  MOVFF  16,FF6
000B2:  MOVFF  17,FF7
000B6:  MOVFF  18,FF8
000BA:  MOVFF  19,FFB
000BE:  MOVF   04,W
000C0:  MOVFF  06,FE0
000C4:  MOVFF  05,FD8
000C8:  RETFIE 0


The file that does work has none of that and no code until valid code starts.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 26, 2019 7:59 am     Reply with quote

That's the CCS interrupt dispatcher code. You will get that code
generated if you have #int_ext and #int_rda in your program.
For example, the program below will generate that code:
Code:

#include <18F87K22.h>
#fuses NOWDT
#use delay(internal=4M)
#use rs232(UART1, baud=38400, errors)

//----------------------
#int_ext
void ext_isr(void)
{
int8 temp;

temp = 0x55;  // dummy code
}


//----------------------
#int_rda
void rda_isr(void)
{
char c;

c = getc();
}

//==========================
void main()
{


while(TRUE);
}   
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Apr 27, 2019 12:34 am     Reply with quote

Yes, so there is obviously an enormous difference between the 'running' and
'non running' code, in that the later is using interrupts, and the former is
not.
Something you are doing in the interrupt based code is causing your issue.
You need to look at what you are doing in the interrupts. What triggers them?
What you are doing in the interrupts?. For example, INT_RDA, implies at
least one character has been received, and _requires_ your 'handler' to
read that character. If it doesn't, the interrupt cannot be cleared (well actually
it can be cleared, but will reset on the very next instruction). So if INT_RDA
is enabled and the 'handler' doesn't read the character, it'll be called
permanently, and stop the code working.....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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