My learning thread - thanks everyone
Mon Jun 27 2011, 01:42 pm
@ romel_emperado
see this basics of SPI
http://microchippiclessons.blogspot.com/2009/06/spi-tutorial.html
and download code on microchip site
http://www.microchipc.com/sourcecode/
see this basics of SPI
http://microchippiclessons.blogspot.com/2009/06/spi-tutorial.html
and download code on microchip site
http://www.microchipc.com/sourcecode/
Fri Jul 01 2011, 03:03 pm
Im using HI-TECH C for PIC18..
#include<htc.h> unsigned char msb , lsb; unsigned int x,y; void spi_init(); unsigned char read_sensor(); void spi_init(); void main() { spi_init(); TRISD = 0; while(1) { read_sensor(); PORTD = read_sensor(); for(y=0; y<5000; y++); } } void spi_init() { SMP = 1; //Input data sampled at end of data output time CKE = 0; //Transmit occurs on transition from Idle to active clock state CKP = 0; //Idle state for clock is a low level SSPEN = 1; //Enables serial port and configures SCK, SDO, SDI and SS as serial port pins SSPCON1 |= 0b0000; // SPI Master mode, clock = FOSC/4 TRISCbits.RC7 = 0; //Serial Data Out (SDO) TRISBbits.RB0 = 1; //Serial Data In (SDI) TRISBbits.RB1 = 0; //Serial Clock (SCK) TRISCbits.RC0 = 0; //chip select } void spi_send(unsigned char data) { SSPBUF = data; while(!BF); } unsigned char read_sensor() { char dummy; RC0 = 1; // Enable sensor spi_send(0x80); // dummy = SSPBUF; spi_send(0x11); RC0 = 0; // dummy = SSPBUF; for(x=0; x<3000; x++); RC0 = 1; spi_send(0x02); //Read MSB temperature address // dummy = SSPBUF; spi_send(0x00); //Read temperature high msb = SSPBUF; spi_send(0x00); lsb = SSPBUF; RC0 = 0; return msb; }
Sun Jul 03 2011, 04:43 pm
@ omel
ru check it in Proteus if yes then on which device u check
is any serial EEPROM ?
ru check it in Proteus if yes then on which device u check
is any serial EEPROM ?
Sun Jul 03 2011, 04:51 pm
yes I check that in protues .. its working.. Im using tc72 temperature sensor
Fri Jul 15 2011, 05:42 pm
hi guys.. I have question.. does an AVR controller has a Configuration bits like PIC? I mean watchdog, browout reset and etc?
Fri Jul 15 2011, 08:56 pm
@ romel_emperado
yes avr has also fuse settings like internal oscillator , watchdog timer and many more
yes avr has also fuse settings like internal oscillator , watchdog timer and many more
Powered by e107 Forum System