View previous topic :: View next topic |
Author |
Message |
Poster Guest
|
Changed compiler version |
Posted: Thu Feb 01, 2007 8:58 am |
|
|
I changed my compiler version and my program for my pic16f877 cldnt work. But it worked fine previously under e older compiler. Is there a bug? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Thu Feb 01, 2007 9:10 am |
|
|
Are we to assume you changed to another version of CCS "C"?
If so, please give the former and current versions along with the code that will not work... |
|
|
Poster Guest
|
Compiler Version |
Posted: Thu Feb 01, 2007 6:03 pm |
|
|
Was using a demo version 4 and changed to 4.023.
Code: |
setup_spi(SPI_MASTER | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16); |
followed by tx-ing it with printf. |
|
|
frequentguest Guest
|
|
Posted: Thu Feb 01, 2007 6:59 pm |
|
|
I've also experienced some problems using SPI in V4.023. These were cleared up when I reverted back to 4.020. I suggest you contact CCS (as they don't monitor this forum) with your bug. I would do this but my code is 40,000+ lines and I'm having trouble narrowing it down. |
|
|
Poster Guest
|
Error |
Posted: Thu Feb 01, 2007 11:51 pm |
|
|
I got e same error when i reverted to v4.014. Dun have anymore versions.... |
|
|
Poster Guest
|
|
Posted: Sun Feb 04, 2007 6:19 pm |
|
|
Changed to 4.020 also get e same problem. I may have to change compiler and learn how to code all over again.... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 04, 2007 8:16 pm |
|
|
In your post above you just gave one line of code. Do you know
for a fact, based upon looking at the .LST file, that the line you posted
is the cause of the problem ?
If so, can you provide an explanation of the symptoms that you see ?
Is there no SPI output ? Is the clock (SCLK) the wrong frequency ?
What specifically is wrong ?
Can you post a very short, but complete test program that shows the
problem ? See the following post for an example of a test program:
http://www.ccsinfo.com/forum/viewtopic.php?t=24861&start=1
Please post an extremely short test program, similar to the one shown.
Also post the compiler version that causes your test program to fail. |
|
|
Poster Guest
|
|
Posted: Sun Feb 04, 2007 10:13 pm |
|
|
Problem occurs with 4.014, 4.020, 4.023 and i forgot wat version i used that worked... thanks...
Code: |
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main(){
int8 msb,lsb;
int16 result;
output_high(PIN_E2);
setup_spi(SPI_MASTER | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16);
output_high(PIN_A0);
delay_ms(3);
while(true){
output_low(PIN_E2);
msb=spi_read(0x00);
lsb=spi_read(0x00);
output_high(PIN_E2);
result = make16(msb, lsb);
result &= 0x1FFE;
result >>= 1;
printf("%lx\n\r", result);
delay_ms(4);
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 04, 2007 10:27 pm |
|
|
1. What chip are trying to talk to with SPI ?
2. What is the specific problem ? |
|
|
Poster Guest
|
|
Posted: Mon Feb 05, 2007 12:24 am |
|
|
Hi PCM Programmer,
I believe you were the one who helped me with the program the other time. It is communicating with an ADS7816. Output from the PIC is just 0x0000 no matter wat the input to the ADC is. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 05, 2007 1:05 am |
|
|
Quote: |
From your program:
setup_spi(SPI_MASTER | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16); |
Read the old thread. Look at my comments near the end of the thread.
I said that you needed to use SPI mode 0.
http://www.ccsinfo.com/forum/viewtopic.php?t=28855
Look at the following table of SPI modes (created by ckielstra).
You can see that the setting in your code above is not a defined mode.
You need to change your code so it uses SPI Mode 0.
Code: |
#define SPI_MODE_0_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_0_1 (SPI_L_TO_H)
#define SPI_MODE_1_0 (SPI_H_TO_L)
#define SPI_MODE_1_1 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
|
Just add those four #define statements above main(), and then
modify your setup_spi() so it looks like this:
Code: |
setup_spi(SPI_MASTER | SPI_MODE_0_0 | SPI_CLK_DIV_16);
|
Then you will have the proper SPI mode. |
|
|
Poster Guest
|
|
Posted: Mon Feb 05, 2007 4:34 am |
|
|
Thanks for ya help PCM programmer,
I just copied the code in but all i get in hyperterminal is 0fff. When i place the SDI (RC4) pin to 0V i get 0000 and when i place it to the 5V pin i get 0fff which is correct. The ADC is not giving the correct input... Previously the program worked... quite curious why now it doesnt... i m currently using version 4.020....
CCS Technical Support does not monitor this forum on a regular basis. Please do not post bug reports to this form. All bug reports should be emailed to support@ccsinfo.com. Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 05, 2007 2:45 pm |
|
|
I guess Admin added that to your post.
Do you still have an older version of the compiler, or can you get one,
such as vs. 3.249 ? If so, try it with that version. See if it still fails.
If both versions fail, then your hardware is likely the problem.
If you can confirm that it works with an earlier version, and if
you can post that version number, then I can compare the .LST files
between those two versions and probably find the problem and give
you a work-around. But you've got to try it with an older version. |
|
|
Poster Guest
|
|
Posted: Mon Feb 05, 2007 9:52 pm |
|
|
I knew it worked with a version 4.XXX and I've tried 4.014, 4.020, 4.023 and they all do not work and i forgot wat was the one i had before that. I've changed my ADC and PIC to new ones also no difference. Super at loss now what to do.. the learning curve for HI-TECH PICC is so high and my dateline for the project is coming up. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 05, 2007 9:58 pm |
|
|
Quote: | I knew it worked with a version 4.XXX |
The problem could be your compiler version or it could be your hardware.
I need precise data to solve the problem. I'm not getting that, so I can't
do any more on this topic. |
|
|
|