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

RS232 Stream with data of 0x00 - this ones for Ttelmah
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
Guest







PostPosted: Mon Aug 21, 2006 4:51 am     Reply with quote

Hi Simon,
I started typing my reply, before your reply appeared. Unfortunately, by the time you have taken a few phone calls etc., ten minutes have 'whizzed' round.
I would though still add the ammendment to use a global variable. If you call the function four times (say), with a seperate counter definition in each, depending on the age of the compiler, you may either get problems, or will end up with four seperate variables, all using space (the latter compiler treats a variable defined this way as 'global', but redefines it each time the routine is called!...).
So if you use the 'inline' declaration as you show, and call the function four times, you get (in the sym file):
Code:

023     i
024     i
025     i
026     i

Which is rather a waste. If instead you use the sigle global variable, you only get one location used for the counter.

Best Wishes
MikeW



Joined: 15 Sep 2003
Posts: 185
Location: Warrington UK

View user's profile Send private message

PostPosted: Mon Aug 21, 2006 4:57 am     Reply with quote

Simon,
sorry it wont compile on 3.249

I get a " a numeric expression must appear here"

below is a complete cut down version for you to try

#include "16F88.h"
//#device *=16
//#device ICD=TRUE
#device adc=8
#FUSES WDT //Watch Dog Timer
#FUSES HS
#fuses MCLR
#fuses NOLVP
#FUSES PUT
#FUSES BROWNOUT
#FUSES NOCPD
#FUSES NOWRT
#FUSES NOPROTECT
#FUSES FCMEN
//#FUSES IESC


#use delay(clock=20000000,RESTART_WDT)
#use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2,bits=8,stream=PC)

char const command_Cam_OFF[] = {0x81,0x01,0x04,0x00,0x03,0xFF};

#define Send_Command(String) {int8 i; for(i=0; i<sizeof(String);i++) {fputc (String)[i],PC);}}


void Init_PIC()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL);
setup_wdt(WDT_1152MS);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
setup_timer_2(T2_DIV_BY_16,241,13);
setup_comparator(NC_NC_NC_NC);


setup_oscillator(False);
set_TRIS_A(0x00);

set_TRIS_B(0x00);
}


#define Test_LED PIN_A4

void main()
{
int8 i;

Init_PIC();

Send_Command(command_Cam_OFF); // error is here

delay_ms(500);


while (1)
{
delay_ms(2000);
output_toggle(Test_LED);
delay_ms(2000);
}
}
Ttelmah
Guest







PostPosted: Mon Aug 21, 2006 5:11 am     Reply with quote

Get rid of the closing bracket after the word string, in the fputc.
Realistically, I'd also avoid using the word 'string', since this accepts a character array, not a 'string', and in many languages, this is a reserved keyword.
Also see my comments about declaring the variable 'globally', rather than in each call.

Best Wishes
MikeW



Joined: 15 Sep 2003
Posts: 185
Location: Warrington UK

View user's profile Send private message

PostPosted: Mon Aug 21, 2006 5:25 am     Reply with quote

Ttelmah,

at last, the bloody thing works !!!

I note your comments about using a potentially reserved word.

also the use of global integer to save ram

many thanks to both you and Simon

Mike
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Mon Aug 21, 2006 5:45 am     Reply with quote

Mike, glad you finally got it going.

Ttelmah,

Quote:
I started typing my reply, before your reply appeared. Unfortunately, by the time you have taken a few phone calls etc., ten minutes have 'whizzed' round.


No problem, I did this the other night myself. It took me 25 minutes to write a reply and test some code, during which time 12 other posts had already been posted sorting the problem !!! Shocked
_________________
Regards,
Simon.
Ttelmah
Guest







PostPosted: Mon Aug 21, 2006 7:15 am     Reply with quote

Yes, there have been threads in the past, where something like five people, all with basically the 'same' answer, post together. I don't know what the 'record' for overlapped posts actually is, but it can be quite 'fun' at times.
Did I see you were from over in Cheshire?. My family 'roots', go back over that way (actually, Germany, then into the Vale of Evesham, then into Cheshire, then emigrated to America, then back over to East London, and into Essex where I am... :-).

Best Wishes
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