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 CCS Technical Support

Last changed IO sets other pin to low

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
2xhp



Joined: 14 Jan 2019
Posts: 39

View user's profile Send private message

Last changed IO sets other pin to low
PostPosted: Mon Jan 14, 2019 11:33 pm     Reply with quote

I'm using a 12F615 with PCM 4.016. When I set an IO pin right after setting another, the first pin is always set to low. The last pin set outputs the correct value.

I've stripped out a bunch of code to get it to the most basic example. Nothing I've tried has changed the behavior. I'm out of ideas and hoping one of the geniuses here has some.

Code:

#include <12f615.h>

#fuses IOSC8,INTRC_IO,NOWDT,NOMCLR,NOBROWNOUT,NOPUT,NOPROTECT

#use delay(clock=8000000)

void main() {

     while(1) {
      output_high(PIN_A0);
      output_high(PIN_A1);   
      delay_ms(50);
      output_low(PIN_A0);
      output_low(PIN_A1);      
      delay_ms(50);
     }
}


List file:


    CCS PCM C Compiler, Version 4.016, xxxxx 14-Jan-19 22:30

    Filename: C:\TestFile.lst

    ROM used: 52 words (5%)
    Largest free fragment is 972
    RAM used: 5 (7%) at main() level
    6 (9%) worst case
    Stack: 1 locations

    *
    0000: MOVLW 00
    0001: MOVWF 0A
    0002: GOTO 018
    0003: NOP
    .................... #include <12f615.h>
    .................... //////// Standard Header file for the PIC12F615 device ////////////////
    .................... #device PIC12F615
    .................... #list
    ....................
    ....................
    .................... #fuses IOSC8,INTRC_IO,NOWDT,NOMCLR,NOBROWNOUT,NOPUT,NOPROTECT
    ....................
    .................... #use delay(clock=8000000)
    0004: MOVLW 46
    0005: MOVWF 04
    0006: BCF 03.7
    0007: MOVF 00,W
    0008: BTFSC 03.2
    0009: GOTO 017
    000A: MOVLW 02
    000B: MOVWF 41
    000C: CLRF 40
    000D: DECFSZ 40,F
    000E: GOTO 00D
    000F: DECFSZ 41,F
    0010: GOTO 00C
    0011: MOVLW 97
    0012: MOVWF 40
    0013: DECFSZ 40,F
    0014: GOTO 013
    0015: DECFSZ 00,F
    0016: GOTO 00A
    0017: RETLW 00
    ....................
    .................... void main() {
    0018: CLRF 04
    0019: BCF 03.7
    001A: MOVLW 1F
    001B: ANDWF 03,F
    ....................
    .................... while(1) {
    .................... output_high(PIN_A0);
    001C: BSF 03.5
    001D: BCF 05.0
    001E: BCF 03.5
    001F: BSF 05.0
    .................... output_high(PIN_A1);
    0020: BSF 03.5
    0021: BCF 05.1
    0022: BCF 03.5
    0023: BSF 05.1
    .................... delay_ms(50);
    0024: MOVLW 32
    0025: MOVWF 46
    0026: CALL 004
    .................... output_low(PIN_A0);
    0027: BSF 03.5
    0028: BCF 05.0
    0029: BCF 03.5
    002A: BCF 05.0
    .................... output_low(PIN_A1);
    002B: BSF 03.5
    002C: BCF 05.1
    002D: BCF 03.5
    002E: BCF 05.1
    .................... delay_ms(50);
    002F: MOVLW 32
    0030: MOVWF 46
    0031: CALL 004
    .................... }
    0032: GOTO 01C
    .................... }
    0033: SLEEP

    Configuration Fuses:
    Word 1: 3CD4 INTRC_IO NOPROTECT IOSC8 NOMCLR NOBROWNOUT NOWDT NOPUT


Thanks in advance.
2xhp



Joined: 14 Jan 2019
Posts: 39

View user's profile Send private message

Problem solved
PostPosted: Tue Jan 15, 2019 12:19 am     Reply with quote

Apparently, there's a bug in my old compiler version. I downloaded the 45 day demo and it works correctly. That's both relieving and frustrating (relieving that I din't have to keep digging - frustrating that I have to upgrade when the version I have *should* work).
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 15, 2019 12:32 am     Reply with quote

Your version doesn't turn off the analog inputs in the main() start-up code.
Current versions do that. You can probably fix the problem by adding
the line shown in bold below at the start of main(). Example:
Quote:
void main() {

setup_adc_ports(NO_ANALOGS);
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Jan 15, 2019 12:32 am     Reply with quote

Well, 4.016, was at best a beta.
If you had something like 4.141, it should work, but V4 didn't start
properly working for a lot of versions.
Seriously also, 4.016, must be at least 10 years old.

In fact though, what is posted is correct code, so I suspect
PCM_Programmer is right, that the problem is the analog ports are
still enabled. Disassembly comments below:
Code:

.................... output_high(PIN_A0);
001C: BSF 03.5 //select bank 1
001D: BCF 05.0 //clear the TRIS 0 bit (set pin as output)
001E: BCF 03.5 //select bank 0
001F: BSF 05.0 //set the output bit 0 high
.................... output_high(PIN_A1);
0020: BSF 03.5 //bank 1
0021: BCF 05.1 //pin 1 set as output
0022: BCF 03.5 //bank 0
0023: BSF 05.1 //set output bit 1 high
.................... delay_ms(50)

So the code is doing exactly what it needs to do to set just the specified
bit.

Can confirm that the code to automatically setup to digital appeared
about half a dozen compiler versions later, and that with this added
the old compiler works fine.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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