Discussion in "8051 Discussion Forum" started by    romel_emperado    Nov 4, 2010.
Tue Jun 14 2011, 06:33 am
thanks majoka..|

I have another question now about gsm modem.. hehe

I know that Some gsm modem can communicate through GPRS but I dont understad how that works..

can you guys explain something about connecting to gprs network using gsm modem?..

I know gprs Im using that when I surf to net with my mobile before with google and facebook.... hehe.. but I know how the gsm modem uses gprs for communication... hekheke



To open GPRS connection:
AT+CSTT="APN","username","password"
AT+CIICR
AT+CIFSR




username and password? hmm where do I get that username and password.. and how about that apn? is that the apn of my ISP?
Tue Jun 14 2011, 02:08 pm
these are the information that are provided by service center
Thu Jun 16 2011, 02:05 am
>>username and password? hmm where do I get that username and password.. and how about that apn? is that the apn of my ISP?

better call customer support for all your queries...
Thu Jun 16 2011, 04:07 pm
these all data is provided by customer service center
Thu Jun 16 2011, 04:12 pm


let say ur using pic16f series with 4MHZ crystal
use timer interrupt or with out interrupt as u want
now clock divide osc by 4 so
MC= 4MHZ/4=1MHZ=1us
now let generate a 50ms delay formula is
delay=(65536-x)*1us
50ms=(65536-x)*1us
50,000=65536-x
x=65536-50,000
x=15536
convert it into hex values and load it with timer registers

majoka




majoka I dont get it where to insert result of the said calculation.. as I read into the datasheet I think timer1 needs the calculation.. we cant put 65536 in timer0 because it is only 8bits timer.. am i right?





#include<htc.c>


/*
 *	Example code for using timer0 on a 16F84
 *	Just sets up a 1 second interrupt and increments a variable
 */

/*
 *	Calculate preload value for one second timer
 */

#define	PERIOD	1000000// period in uS - one second here
#define	XTAL	4000000// crystal frequency - 4MHz

#define IPERIOD	(4 * 1000000 / XTAL)// Period of instruction clock in uSeconds

#define	SCALE	256// Timer 0 prescaler
#define T0_TICKS 256// Number of counts for interrupt

#define TICK_PERIOD (SCALE * IPERIOD)// Period (uSec) of one increment of timer 0

#define	RELOADS	((PERIOD/T0_TICKS)/TICK_PERIOD)

unsigned long	seconds;	// second count
near char reload = 0;

/* service routine for timer 0 interrupt */
void interrupt
timer0_isr(void)
{
	if(reload == 0){
		// effect a change on PORTB whenever our desired period is reached.
		// Note this timing will contain a margin of error.
		reload = RELOADS + 1;
		seconds++;
		PORTB++;	// effect a change on PORTB
	}
	reload--;
	T0IF = 0;
}

main()
{
	// initialize timer 0; 
	
	OPTION = 0b00000111;	// prescale by 256
	T0CS = 0;			// select internal clock
	T0IE = 1;			// enable timer interrupt
	GIE = 1;			// enable global interrupts
	TRISB = 0;			// output changes on LED
	
	for(;;)
		continue;		// let interrupt do its job
}



HOw about if I use 12Mhz crystal. can i directly change this line according to the crystall value?

#define	XTAL	4000000  

/* change 4mhz to 12Mhz */

  #define	XTAL	12000000	


[ Edited Thu Jun 16 2011, 09:10 pm ]
Thu Jun 16 2011, 06:22 pm
guys.. I made this code to toggle a led every 1 second using timer 0.. but how do I calculate the prescaler to generate 1 second?

let say Im using 11.0592Mhz crystal..

#include<pic.h>



void interrupt isr(void)
{
  RB0 ^= 1;  //toggle LED
  T0IF = 0;  //clear interrupt flag..

}


void main(void)
{
	TRISB = 0b11111110; //set bit 1 of portB as output.
	
	T0IE = 1;  // enable timer 0 interrrupt
	GIE =1;    // Enable global interrupt 
	T0CS = 0;  // timer 0 Internal clock source
	
	OPTION_REG = 0b0111;  // set prescaler to timer 0 and 1:256 prescaler..
	while(1);

}

Fri Jun 17 2011, 04:06 am
I know the solution of my problem hehe.. will solve it later... hehe I will attend my class first..
Fri Jun 17 2011, 05:39 pm
I've got it working.. hihihihi

#include<pic.h>


__CONFIG(0x3F38); //for Internal oscillator

char count;

void interrupt timer0()
{
	
    
	if(T0IF == 1)
	{
	    T0IF = 0;
	    count++;
		if(count == 15)
		{
			RA2 ^= 1;  //toggle LED
			count = 0;
			
		}
		PEIE = 0; //Disables all peripheral interrupts
	}
}


void main(void)
{

	TMR0 = 0;
	OPTION_REG = 0b0111;  // set prescaler to timer 0 and 1:256 prescaler..
	T0CS = 0;  // timer 0 Internal clock source
	T0IE = 1;  // enable timer 0 interrrupt
	GIE =1;    // Enable global interrupt 
	TRISA2 = 0; //set bit 1 of portB as output.

	while(1);

}

Sat Jun 18 2011, 02:39 am
keep it up
Mon Jun 27 2011, 06:59 am
guys Im in a process of learning SPI protocol using PIC18f4550

Im initializing the SPI mode as I read based on the datasheet but can you give me a hand on how to have a basic transmit and receive of data?


#include <htc.h>




void SPI_init();


void main()
{
	SPI_init(); // initialize SPI mode
	while(1)
   {
		
   }
}



void SPI_init()
{
	/* Enables serial port and configures SCK, SDO, SDI and SS as serial port pins */
	SSPCON1 = 0b00100000;

	/* Input data sampled at end of data output time
	   Transmit occurs on transition from active to Idle clock state */
	SSPSTAT = 0b11000000;

	TRISCbits.TRISC7 = 0; //SD0 set as output

	  
	TRISBbits.TRISB0 = 1; //SDI set as input

	TRISBbits.TRISB1 = 0; //SCK set as output 
	
	TRISCbits.TRISC2 = 0; //CS set as output

	
}

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am