Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About learner

  • Rank
  1. Hi all there I am new to microcontrollers. I am doing a project in which i have to communicate with 1 wire device. I have to use the bit banging method to communicate. Can any1 plzz put some example code in C or any good links to understand it. thanks regards
  2. can some1 please help me how to convert a string to integer or floating point number. i will appretiate if you explain it using an example . string_X[6]="12345"; and i have to covert it to a integer and floating point number thanks learner
  3. Hi there thanks for all the explaination. it really worked out apart from few small changes using diff PIC. i really appretiate that. now do u have any idea how to get the specific part from within a long string for example if the original string is AAAA+BBBB+CCCC+DDDD+EEEE and from that string i want to take out only CCCC. thanks learner I have used the PWM in PIC16F72. You may have to sightly modify for the PIC18. It generates a 38khz for IR communication as carrier frequency. #include <system.h> #pragma CLOCK_FREQ 20000000 // config clock to 20mhz. // Set configuration fuse. #pragma DATA _CONFIG, _HS_OSC & _WDT_ON & _CP_OFF & _PWRTE_OFF void main(void) { trisa = 255; trisb = 0; trisc=0; //set all portc pins as output pins. portc=0; //make all portc pins low. option_reg = 0b11111111; // using 1:32 prescaler for wtd. //wtd will awaken from sleep mode.wtd uses internal rc for its clock. //wtd gives a min of 7ms typ of 18ms or 33ms of max time out period. /*lets configure the pwm module for 38khz. formula for pwm period = [(pw2)+1].4.tosc.(tmr2 prescaler value) lets take tosc as 20mhz as it will result in better resolution then 4mhz. tosc = 1/20000000; pwm period = 1/38000; therefore pr2 +1 = 132; with pr2 as 131 the generated pwm freq is = 37.8787khz. ******************************* we choose pr2 = 131; * ******************************* duty cycle = (ccpr1l:ccp1con<5:4)*tosc*(tmr2 prescale value) lets assume 50% duty cycle.ie. 50% on time 50% off time. duty cycle = (1/37878)/2 = 1.32*10^-5. which is = ccp_duty_value/20,000000 **************************************** ccp_duty_value = (1.32*10^-5)*20000000 * = 264; * **************************************** note:ccpr1l contains MSB & ccp1con contains the LSB total of 10bits. ****************************** so load ccpr1l = 0b01000010; ****************************** the two bits of ccp1con is not required to be filled. */ pr2 = 131; ccpr1l = 0b01000010; //for a duty cycle value of 264. ccp1con = 0b00001100; //11xx=pwm mode /*timer2 control register we have selected bit7.....unimplemented.read as 0. bit6-3...(0000) 1:1 for post scaler, not used in pwm. but can be used as servo feed back. bit2.....(1) timer2 on bit1-0...(00) prescaler is 1. */ t2con = 0b00000100; while(1); } Leave the WDT alone as its got nothing to do with the PWM. Regards Raghunathan
  4. Hi there Can any 1 help me out with how to generate PWM using PIC18F4520 using BOOST C compiler.
  • Create New...