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

Programming 16f877a on the air
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
umutso



Joined: 23 Jan 2013
Posts: 39
Location: turkey

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 18, 2013 8:05 am     Reply with quote

thats all right completely Gabriel.
_________________
Umut Sonkurt
Gabriel



Joined: 03 Aug 2009
Posts: 1085
Location: Panama

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 8:29 am     Reply with quote

right,

so just send to the pic via GPRS the new Alarm time...


G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
umutso



Joined: 23 Jan 2013
Posts: 39
Location: turkey

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 18, 2013 9:06 am     Reply with quote

Gabriel,

I do not know how to do this..
_________________
Umut Sonkurt
Gabriel



Joined: 03 Aug 2009
Posts: 1085
Location: Panama

View user's profile Send private message

PostPosted: Mon Feb 18, 2013 9:21 am     Reply with quote

you can send data _from_ the PIC, but not Send data _to_ the PIC?

how do you check/calculate the current time vs alarm time and how do you calculate what the Next alarm time is?

post your code.

What is it that you cant do? modify the pic code to accept changing values or send data form the PC or end point via GPRS to the PIC?



G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
umutso



Joined: 23 Jan 2013
Posts: 39
Location: turkey

View user's profile Send private message MSN Messenger

PostPosted: Tue Feb 19, 2013 7:54 am     Reply with quote

Hello All,

I can get serial data from the controller and send to the controller. But what I do not know or can not do is ;

Code:

#use rs232(baud=9600, xmit=PIN_C6,rcv=pin_C7, parity=N, stop=1, stream=OUT_STREAM ) //Sets up serial port output pin & baud rate
#org 0x1F00, 0x1FFF void loader16F877A(void) {}

void main() {
int16 j;
int16 x;
delay_ms(1000);
   setup_timer_1(T1_INTERNAL | T1_DIV_BY_2);
   output_low(PIN_B1);   

fputs("ECHO:",OUT_STREAM);
while(true)
{
j=fgetc(OUT_STREAM);
putc(j,OUT_STREAM);

}
}

here is a simple code. I can echo via rs232 what I send to the controller receive back. What I can not do is I need to set the x variable what I sent (for Eg : "3000") and will use it with delay_ms ; like delay_ms(x); instead of delay_ms(3000);

If I can learn how to do this then I can set other variables and I can operate the commands I send via serial.

This was the question I mentioned that How can I?
_________________
Umut Sonkurt
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

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

PostPosted: Tue Feb 19, 2013 9:42 am     Reply with quote

If *I* needed a variable delay, then what I'd do is set up a timer to interrupt on a regular basis and increment or decrement a counter. Your main line monitors the counter until the required number of ticks have taken place. eg
Code:
/* * * * * * * * * *
 * 100th sec tick  *
 * * * * * * * * * */

#define TICKS_PER_SEC 100
#define MS_TO_TICKS(MS) (TICKS_PER_SEC*MS/1000)

uint32_t ticks;

#int_CCP1
void CCP1_isr(void)
{
  ++ticks;
}

uint32_t get_ticks(void)
{
  uint32_t ret;
  disable_interrupts(GLOBAL);
  ret = ticks;
  enable_interrupts(GLOBAL);
  return ret;
}

// obtain a 10ms interrupt tick
// using CCP1 to interrupt and reset so no ticks are lost handling the interrupt
void tick_init(void)
{
  CCP_1 = (getenv("CLOCK")/4/8/TICKS_PER_SEC-1);
  set_timer3(0);
  setup_timer_3(T3_INTERNAL | T3_DIV_BY_8 | T3_CCP1_TO_2);
  setup_ccp1(CCP_COMPARE_RESET_TIMER);
  enable_interrupts(INT_CCP1);
}
Then:
Code:
main()
{
  uint32_t end;
  tick_init();
  enable_interrupts(GLOBAL);
  // wait 1000ms...
  end = get_ticks() + MS_TO_TICKS(1000);
  while (get_ticks() < end)
  {
    // optionally do stuff here
  }
  // .. continue
}

There are probably as many different (and correct) ways of doing this as there are members of this forum!
_________________
Andrew
Gabriel



Joined: 03 Aug 2009
Posts: 1085
Location: Panama

View user's profile Send private message

PostPosted: Tue Feb 19, 2013 12:05 pm     Reply with quote

@umutso:

so, your problem is that you dont know how to take data from your buffer like:

//Start_Pseudo_Code(Now);

assume these are the contents of your buffer as received via serial
Code:
Buffer[4]={ '3','0','0','0'};


and turn it into:

Assume 3000 is the value extracted from the buffer above.
Code:
int16 Var = 3000;



so that you may be able to do something like:

Code:
eeprom_write(address, Var);

and then;

Code:
Wakeup_delay_ms(eeprom_read(address);



Solution:
Read the manual: ATOI();



G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
umutso



Joined: 23 Jan 2013
Posts: 39
Location: turkey

View user's profile Send private message MSN Messenger

PostPosted: Tue Feb 19, 2013 12:14 pm     Reply with quote

Gabriel

İ get it totally. İ will try this tomorrow morning first place. Thank you so much for this very simple guiding. İt helped a lot. İ understand the idea. Let me try it first and i will let you know.
_________________
Umut Sonkurt
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