|
|
View previous topic :: View next topic |
Author |
Message |
nlei_datelka
Joined: 06 Mar 2007 Posts: 3
|
Strange problem with ccs 4 compiler version |
Posted: Tue Mar 06, 2007 9:09 am |
|
|
Hi,
I'm having some problems with the new ccs 4 compiler.
The 1st problem is that 4.27 version crashes on install............
The 2nd is strange behavior with 4.25 version....
this code
Code: |
#define PRSPEED 4000000 // em Hz
#include <16F648A>
//#use standard_io( A )
#use fixed_io(a_outputs=PIN_A0,PIN_A1,PIN_A2 )
#use standard_io( B )
#fuses INTRC,NOWDT,NOPROTECT,NOLVP
#use delay(clock=PRSPEED)
#include "DefinesM.h"
void main(){
BYTE SerialC; // o q aparece na porta serie
// int TMCounter=0;
BOOLEAN LINBTM=0; // botao estado
BOOLEAN PRGJMP=0; // jumper programa磯
//unsigned int dbglog=0;
fputc('0',COM_A);
//TIMER 0 interrupt at .1s
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); // funcao interna ao PIC dividir o clk por 256
port_b_pullups(true); // coloca pull up R nos porto B
// port_a_pullups(true);
enable_interrupts(GLOBAL); // fazer enable das interrupts
enable_interrupts(INT_RTCC);
// enable_interrupts(INT_RDA);
// enable_interrupts(INT_TBE);
// set_tris_a(0xF8); // definir In Outs o q esta a 1 sao entradas
output_low(PINRL); // default low
output_low(PINOK);
output_low(PINER);
//pb fprintf(COM_A,"r\nMain-1");
//pb initTerm(); // utils.c
fputc('1',COM_A);//pb
delay_ms(255); // em ms
// bputc('9');//pb fprintf(COM_A,"Main-2");
///////////////////////////////////////////////////////////////////////////////////
while (TRUE) {
delay_ms(255); // entre ciclos esperas 255 ms
delay_ms(255); // entre ciclos esperas 255 ms
delay_ms(255); // entre ciclos esperas 255 ms
delay_ms(255); // entre ciclos esperas 255 ms
if(LINBTM==0){
LINBTM=1;
output_high(PIN_A1);
delay_ms(255); // entre ciclos esperas 255 ms
delay_ms(255); // entre ciclos esperas 255 ms
output_high(PIN_A0);
delay_ms(255); // entre ciclos esperas 255 ms
delay_ms(255); // entre ciclos esperas 255 ms
output_high(PIN_A2); // default low
}else{
LINBTM=0;
output_low(PIN_A1);
delay_ms(255); // entre ciclos esperas 255 ms
delay_ms(255); // entre ciclos esperas 255 ms
output_low(PIN_A0);
delay_ms(255); // entre ciclos esperas 255 ms
delay_ms(255); // entre ciclos esperas 255 ms
output_low(PIN_A2); //
}
|
Should turn on 3 outputs sequentially and it works fine with version 3 compilers, but with version 4 it only turns on one each time.......
one other problem is that the example code to load words from memory don't work with version 4.25 compiler. the higher byte loads 0......
Best regards...... _________________ -------------------------
Nuno Leit�o |
|
|
Ttelmah Guest
|
|
Posted: Tue Mar 06, 2007 10:01 am |
|
|
If you are going to post code to show a problem, then post a small program that can work. What you have posted here, cannot work without other code (you enable an interrupt without a handler for example), and have RS232 without a #use.
The 'load words from memory' problem, is almost certainly the known problem with the change of pointer types (to correct C syntax), in V4. In the past, incrementing a pointer moved you to the next byte. Now it moves you to the next element of the same type. Hence if you use the address of an int16 (for example), and want to access the second byte, then you have to use:
b2=*(int8 *)&longval;
This has caused problems with quite a few of the older libraries (math.h for example), but is generally easily fixed.
An example of making the second half of your code look a lot tidier:
Code: |
while (TRUE) {
delay_ms(1020); // wait 1020mSec
if(LINBTM=!LINBTM){
//Now operate each pin in turn, 510mSec apart
output_low(PIN_A1);
delay_ms(510);
output_low(PIN_A0);
delay_ms(510);
output_low(PIN_A2);
}
else{
//As above, but on alternate loops
output_high(PIN_A1);
delay_ms(510);
output_high(PIN_A0);
delay_ms(510);
output_high(PIN_A2);
}
}
|
What happens if you switch to using standard_io?.
Best Wishes |
|
|
nlei_datelka
Joined: 06 Mar 2007 Posts: 3
|
|
Posted: Tue Mar 06, 2007 3:53 pm |
|
|
That code is part of one bigger program that works fine with version 3 compiler. (Sory for the portuguese coments)
The code you post have the same problem. Can't turn on all the outputs. When I turn on the second output it turns the first off . _________________ -------------------------
Nuno Leit�o |
|
|
Ttelmah Guest
|
|
Posted: Tue Mar 06, 2007 4:32 pm |
|
|
I'm sorry, but you have changed something on your hardware since it worked.
I have just tried this code, with 4.025, and 4.027, and both run fine. I tried both standard I/O, and fixed I/O modes.
The obvious thing would be the 'classic' RMW problem with too much load on the pins.
Best Wishes |
|
|
nlei_datelka
Joined: 06 Mar 2007 Posts: 3
|
|
Posted: Mon Mar 12, 2007 3:56 pm |
|
|
No that is not the problem becouse the board is the same that works with compiler version 3. _________________ -------------------------
Nuno Leit�o |
|
|
airjack
Joined: 02 Mar 2007 Posts: 2
|
|
Posted: Mon Mar 12, 2007 10:37 pm |
|
|
Hi
I think the problem caused by the different initial registers setup by Ver 3and Ver4, I had the same problem with use PIN_A0,PIN_A1,PINA2 replace the PIN_B0, PIN_B1,PIN_B2 used in the lcd_420.c, in the ver3 LCD work well,But
with VER 4 it not work. I check the behaver of these pin with logic analyzer, I
found that PIN_A1 is vary strange when set to high. It look like a trigger signal when set to high, just high 1 instruction cycle then went to low in Ver 4. But with Ver 3 the high low will follow by the code setup . Then I had check the initial code for the different version, I found it is different for the initial register setup. So I back work with Ver 3 now. It seems that Ver 4 still have some unknown bug exist. I still check with newly Ver4 but still not work. Maybe I 'll start to count when CCS will fix this bug. |
|
|
|
|
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
|