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

problems with 16F690

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



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

problems with 16F690
PostPosted: Thu Dec 06, 2007 10:47 am     Reply with quote

I've had some strange problems programming the 16F690 chip using my ver.3.223 compiler. Can anyone tell me if there are some bugs in the ocmpiler specific to that chip? I have programmed many other chips using the same functions, etc and had no problem. In fact, this code was all written and working in a 12f683 before upgrading for more I/O.

The craziness started when I couldn't use:
#use fixed_io(b_outputs=PIN_B7)
the compiler generated an error.

then, I couldn't use:
setup_timer_2(T2_DIV_BY_1, PwmPeriod*2, 1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(PwmOnTimeUs*2);
even though they worked perfectly in the other chip. So I read the datasheet and set it all up thru the registers...old school!

Then my getstring() was misreading input. I finally fixed it by moving
the array "int s[6] " from local to global. The characters were read correctly again.

Then the display of D numbers was garbled, although the LU were fine. Prior to that last change they were displayed correctly. But I was able to get them working by changing from printf("%d",var) to printf("%lu",(int16)var);

I just shipped the demo with my fingers crossed. But I just want to know if these appear to be known compiler issues, or what. As I said, I've done nothing unusual in this program. It was working fine in another chip. And I've written many many programs in many many microchip parts without problems. And I was writing what should have been easy - done it all before - kind of stuff.

Thoughts?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 06, 2007 11:45 am     Reply with quote

Post a short, but complete test program that demonstrates one of these
problems. Post all #include, #fuses, and #use statements. Post all
variable and constant declarations. The program should be compilable
without errors. Make it very short.
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

Here is the output port problem.
PostPosted: Thu Dec 06, 2007 12:42 pm     Reply with quote

Okay, one at a time. This is the first problem I had, with the error msg in the comment.

#include <16F690.h>
#fuses NOWDT,PUT,NOPROTECT,BROWNOUT,MCLR,INTRC_IO
#device ADC=10
#use delay(clock=8000000)
#use fixed_io(b_outputs=PIN_B7) // this line won't compile for some reason - Line 44(5,74): Option invalid Not a valid port: B_OUTPUTS
#use fixed_io(C_outputs=PIN_C7) // this line works fine

#USE RS232(Baud=19200,XMIT=PIN_B7,RCV=PIN_B5,PARITY=N,BITS=8,ERRORS)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 06, 2007 12:49 pm     Reply with quote

That version is defective. Later versions don't have the problem.
I tested it with vs. 3.249 and it compiles OK.
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

Thanks for the quick response!
PostPosted: Thu Dec 06, 2007 12:58 pm     Reply with quote

I was hoping to hear that it was a bad compiler version.
Does it make sense that all of those things could be broken in such a chip specific way? Other chips compiled fine with the exact same code.

Doing the PWM registers by hand and with a datasheet reminds me why I love CCS so much - they let me focus on all my OTHER probems!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 06, 2007 1:12 pm     Reply with quote

That version is defective. See the bug below:
Code:
.................... setup_ccp1(CCP_PWM);   
0031:  MOVLW  7F
0032:  MOVWF  07
0033:  BCF    03.5
0034:  BCF    07.5
0035:  MOVLW  0C
0036:  MOVWF  17   // Load reg 0x17 with 0x0C
0037:  CLRF   17   // Bug -- It clears register 0x17
0038:  CLRF   16


Here is code from vs. 4.064. Note that it doesn't have the bug:
Code:

.................... setup_ccp1(CCP_PWM); 
0031:  MOVLW  7F
0032:  MOVWF  07
0033:  BCF    03.5
0034:  BCF    07.5
0035:  MOVLW  0C
0036:  MOVWF  17
0037:  CLRF   1C
pmuldoon



Joined: 26 Sep 2003
Posts: 218
Location: Northern Indiana

View user's profile Send private message

Great work!
PostPosted: Thu Dec 06, 2007 1:44 pm     Reply with quote

Ha!
Load a register with the correct value... and then clear it!
Why do mistakes always look so much more obvious in hindsight?

Thanks again for the quick research.
You've done in five minutes what I planned on spending an evening doing.
I will upgrade my compiler.
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