caramoan tour package

caramoan tour package

Author Topic: I2C routines for PIC Microcontroller  (Read 8922 times)

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: I2C routines for PIC Microcontroller
« Reply #40 on: October 16, 2009, 05:54:42 PM »
patanong... :D

to be exact sir, ano yung delay.h? nagstruggle ako gumawa ng sariling ds1307 driver. guided na din naman gawa nung driver sa CCSinfo.

parang mas gusto ko to kasi software i2c to di ba?
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Philippine Electronics Forum

Re: I2C routines for PIC Microcontroller
« Reply #40 on: October 16, 2009, 05:54:42 PM »

Offline Kaizer03

  • Nuclear Reactor
  • ****
  • Posts: 4847
  • Pogi/Ganda Points: 225
  • C#<-->Android<-->Java
    • PhilRobotics
Re: I2C routines for PIC Microcontroller
« Reply #41 on: October 16, 2009, 05:57:23 PM »
thanks dito...point for you tita.=)
Lend a hand for those who are in need!=)

Stop Hijacking!=) More Technical Posts!=)
 ;)

Kaizer Killer EX Pre-Alpha

Philippine Electronics Forum

Re: I2C routines for PIC Microcontroller
« Reply #41 on: October 16, 2009, 05:57:23 PM »

Offline zer0w1ng

  • Technical People
  • Gas Turbine
  • *****
  • Posts: 2179
  • Pogi/Ganda Points: 305
  • Gender: Male
  • Enter any 11-digit prime number to continue...
    • The Cebuano Geek
Re: I2C routines for PIC Microcontroller
« Reply #42 on: October 16, 2009, 07:14:54 PM »
patanong... :D

to be exact sir, ano yung delay.h? nagstruggle ako gumawa ng sariling ds1307 driver. guided na din naman gawa nung driver sa CCSinfo.

parang mas gusto ko to kasi software i2c to di ba?

delay.h and together delay.c are included in the hitech compiler standard lib.
This includes polled microsecond and millisecond delays but not so accurate.

Yes this is I2C.
The Cebuano Geek

Philippine Electronics Forum

Re: I2C routines for PIC Microcontroller
« Reply #42 on: October 16, 2009, 07:14:54 PM »

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: I2C routines for PIC Microcontroller
« Reply #43 on: October 16, 2009, 07:20:49 PM »
eto po ba yun?

delay.c
Code: [Select]
/*
 * Delay functions
 * See delay.h for details
 *
 * Make sure this code is compiled with full optimization!!!
 */

#include "delay.h"

void
DelayMs(unsigned char cnt)
{
#if XTAL_FREQ <= 2MHZ
do {
DelayUs(996);
} while(--cnt);
#endif

#if    XTAL_FREQ > 2MHZ
unsigned char i;
do {
i = 4;
do {
DelayUs(250);
} while(--i);
} while(--cnt);
#endif
}

delay.h
Code: [Select]
/*
 * Delay functions for HI-TECH C on the PIC
 *
 * Functions available:
 * DelayUs(x) Delay specified number of microseconds
 * DelayMs(x) Delay specified number of milliseconds
 *
 * Note that there are range limits: x must not exceed 255 - for xtal
 * frequencies > 12MHz the range for DelayUs is even smaller.
 * To use DelayUs it is only necessary to include this file; to use
 * DelayMs you must include delay.c in your project.
 *
 */

/* Set the crystal frequency in the CPP predefined symbols list in
HPDPIC, or on the PICC commmand line, e.g.
picc -DXTAL_FREQ=4MHZ

or
picc -DXTAL_FREQ=100KHZ

Note that this is the crystal frequency, the CPU clock is
divided by 4.

 * MAKE SURE this code is compiled with full optimization!!!

 */

#ifndef XTAL_FREQ
#define XTAL_FREQ 4MHZ /* Crystal frequency in MHz */
#endif

#define MHZ *1000L /* number of kHz in a MHz */
#define KHZ *1 /* number of kHz in a kHz */

#if XTAL_FREQ >= 12MHZ

#define DelayUs(x) { unsigned char _dcnt; \
  _dcnt = (x)*((XTAL_FREQ)/(12MHZ)); \
  while(--_dcnt != 0) \
  continue; }
#else

#define DelayUs(x) { unsigned char _dcnt; \
  _dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \
  while(--_dcnt != 0) \
  continue; }
#endif

extern void DelayMs(unsigned char);


i searched over the folder of hitech c installation, yan lang po ang lumabas. the other delay was promoting the usage of __delay_ms() and __delay_us().
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Philippine Electronics Forum

Re: I2C routines for PIC Microcontroller
« Reply #43 on: October 16, 2009, 07:20:49 PM »

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: I2C routines for PIC Microcontroller
« Reply #44 on: October 16, 2009, 09:09:09 PM »
ano naman yung io.h? dami kong tanong... heheh ;D
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Philippine Electronics Forum

Re: I2C routines for PIC Microcontroller
« Reply #44 on: October 16, 2009, 09:09:09 PM »

Offline zer0w1ng

  • Technical People
  • Gas Turbine
  • *****
  • Posts: 2179
  • Pogi/Ganda Points: 305
  • Gender: Male
  • Enter any 11-digit prime number to continue...
    • The Cebuano Geek
Re: I2C routines for PIC Microcontroller
« Reply #45 on: October 17, 2009, 08:20:15 AM »
ano naman yung io.h? dami kong tanong... heheh ;D

Ok lang.

Sir, ito yung definition ng IO na ginagamit sa I2C.

On the top part sa source code naka-comment ito:
Code: [Select]
//define the following externally on io.h file
/*
 //port pin assignment
 #define SCL             RA5
 #define SCL_TRIS        TRISA5
 #define SDA             RA4
 #define SDA_TRIS        TRISA4
*/

Ito yung laman ng io.h or any ther io definitions sa overall program.
This is a modular concept sa programming para hindi ako malito.
Pwede ring tangalin ang io.h and copy/paste the code inside the .c file.
The Cebuano Geek

Offline marcelino

  • Moderator
  • Solar Power Satellite
  • *****
  • Posts: 6016
  • Pogi/Ganda Points: 258
  • ...keep moving forward! - Robinson's
Re: I2C routines for PIC Microcontroller
« Reply #46 on: October 17, 2009, 10:42:44 AM »
Ok lang.

Sir, ito yung definition ng IO na ginagamit sa I2C.

On the top part sa source code naka-comment ito:
Code: [Select]
//define the following externally on io.h file
/*
 //port pin assignment
 #define SCL             RA5
 #define SCL_TRIS        TRISA5
 #define SDA             RA4
 #define SDA_TRIS        TRISA4
*/

Ito yung laman ng io.h or any ther io definitions sa overall program.
This is a modular concept sa programming para hindi ako malito.
Pwede ring tangalin ang io.h and copy/paste the code inside the .c file.


yes sir, right after ko magpost ng tanong, naintindihan ko na din naman...

thanks :D
"Don't take life seriously. After all, no one has ever come out of it alive. -Bugs Bunny"

Offline bryanwizard

  • CR2032 Battery
  • **
  • Posts: 38
  • Pogi/Ganda Points: 0
Re: I2C routines for PIC Microcontroller
« Reply #47 on: October 06, 2010, 10:15:41 PM »
wow gandang thread po ito. Gusto ko din matuto ng PIC.

ELAN, SONIX, ST lang alam ko.

salamat po master zerowing

Offline believeitornot

  • CR2032 Battery
  • **
  • Posts: 12
  • Pogi/Ganda Points: 0
Re: I2C routines for PIC Microcontroller
« Reply #48 on: July 23, 2012, 10:14:40 PM »
sir,gud day po.
   magtatanong lng po aq if ano pede Enhancement ang pede kong gawin sa pic Microcontroller?my nabasa po aq n lecture note n 3 po ung pede gawing enhancement....processor,memory at peripherals....alin po ba ang astig gawin?at alin po ba ang posible gawin..need ko po ng reply nyo..salamat po

Offline believeitornot

  • CR2032 Battery
  • **
  • Posts: 12
  • Pogi/Ganda Points: 0
Re: I2C routines for PIC Microcontroller
« Reply #49 on: February 05, 2013, 02:42:11 PM »
mga sir,
 

cno po may alam kung magcrack ng PIc mcu...

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: I2C routines for PIC Microcontroller
« Reply #50 on: February 05, 2013, 03:58:57 PM »
mga sir,
 

cno po may alam kung magcrack ng PIc mcu...

Off topic ka boy, gawa ka sariling thread then dun natin pagusapan yan....
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Philippine Electronics Forum

Re: I2C routines for PIC Microcontroller
« Reply #50 on: February 05, 2013, 03:58:57 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com