|
Tài trợ cho PIC Vietnam |
English forum on PICs Forum for foreigners -only English in this forum - Do not need to register or login |
|
Ðiều Chỉnh | Xếp Bài |
23-07-2006, 08:16 AM | #1 |
Đệ tử 2 túi
|
One wire in PIC16F84A
Hi everyone,
I'm just a new "apprentice" in this field. I'm contemporarily learning how to transfer data from one PIC16F84A to the other one, including how to receive the data, of course. I can read and understand MPAsm, Mikro Basic and CCS C quite well; so, if you know about this, you can help me in the aforementioned language. Thank you in advance. B thay đổi nội dung bởi: briantk_1988, 23-07-2006 lúc 08:19 AM. |
23-07-2006, 07:28 PM | #2 | |
Trưởng lão PIC bang
|
Trích:
There are many ways to do what you want, using different interface protocols and standards. Unfortunately, PIC16F84A doesn't give you much power to do a lot of stuff in implementing those protocols and standards. So, could you be more specific on what you are trying to do? What sort of data are you transferring? How fast would you like your data to be transferred? Have you got any idea about the interface protocol/standard? Cheers,
__________________
Biển học mênh mông, sức người có hạn. Đang gặp vấn đề cần được giúp đỡ? Hãy dành ra vài phút đọc luồng sau: http://www.picvietnam.com/forum/showthread.php?t=1263 |
|
23-07-2006, 08:56 PM | #3 |
Đệ tử 2 túi
|
Thanks a lot for replying me.
I'm trying to make a simple calculator. As far as I am concerned, an LCD display requires 6 pins from the microcontroler, a simplest keypad needs 8 more pins --> we need at least 14 IO pins which is impossible for an PIC16F84A. Unfortunately, since I haven't a clue about microcontroler before, I just though everything was the same which made me I got the PIC16F84A. Now, I'm thinking that I might use one PIC6F84A for the keypad and then use one wire interface to transmiss the information to the other one which will manipulate the data and then display in the LCD. I did read the onewire example in MikroBasic but it's not satifiable, for the example is just for getting data from a themometer (DS1820). Furthermore, I think that I don't need a very high speed to do this task. Also, I'm just a novice, I have a very humble idea about interface protocol/standard. So, if anyone have any idea about what i gotta do, I'm very grateful to know. Thanks in advance thay đổi nội dung bởi: briantk_1988, 23-07-2006 lúc 09:03 PM. |
29-07-2006, 10:05 AM | #4 |
Nhập môn đệ tử
Tham gia ngày: Jul 2006
Nơi Cư Ngụ: Sưon South Kỏea
Bài gửi: 6
: |
Chảo Briantk,
I agree with namqn, that the 'f84 is not the best choice. It is old, and has no USART, etc. etc. Next time try a 16F628A, or a 16F88. You can free up some pins by using a 2 wire LCD interface, though. Take a look at this site for the hardware: http://www.rentron.com/Myke1.htm He gives examples in assembly, and somewhere I have source in ccs C to run it. I will try and find my source if you wish to go this route. I'm quite busy these days as I will move back to Canada in 3 weeks, but I'll watch this forum to see if you are interested. Regards |
30-07-2006, 12:46 AM | #5 |
Đệ tử 2 túi
|
Thanks so much. It must be the best that you can provide me with the source in CCS C. I hope you can post it soon
Regards Br |
30-07-2006, 12:49 PM | #6 |
Nhập môn đệ tử
Tham gia ngày: Jul 2006
Nơi Cư Ngụ: Sưon South Kỏea
Bài gửi: 6
: |
Chảo,
I hope this works, but if you have any questions, I'll keep watching here... first the driver Code:
//////////////////////////////////////////////////////////////////////////// //// Library for a 2 wire LCD interface using an 74hc174 //// //// //// //// //// //////////////////////////////////////////////////////////////////////////// #ifndef LCD_clk #define LCD_data PIN_B2 #define LCD_clk PIN_B1 #endif void LCDInit(void) { // Initialize the LCD I/O Pins Dlay = RTC +20; while (Dlay != RTC); LCDNybble(0x003, 0); // send init command Dlay = RTC + 6; // wait > 5 mSec for while (Dlay != RTC); // LCD to accept cmd LCDNybble(0x003, 0); // send init command Dlay = RTC + 1; // wait > 160 uSec for while (Dlay != RTC); // LCD to accept cmd LCDNybble(0x003, 0); // send init command Dlay = RTC + 1; // wait > 160 uSec for while (Dlay != RTC); // LCD to accept cmd LCDNybble(0x002, 0); // send init command 0000 0010 Dlay = RTC + 6; // wait > 5 msec for while (Dlay != RTC); // LCD to accept cmd LCDByte(0x028, 0); // step 6, set operating 0010 1000 LCDByte(0x008, 0); // step 7, display off 0000 1000 LCDByte(0x001, 0); // step 8, clear display 0000 0001 LCDByte(0x006, 0); // step 9, shift 0000 0110 LCDByte(0x00E, 0); // step 10, display on 0000 1110 } // End LCDInit void LCDNybble(char Nybble, char RS) { // Send Nybble to LCD int i; // removed unsigned from before int output_low(PIN_B2); //Data = 0; // Clear the '174 for (i = 0; i < 6; i++) { // Repeat for six bits //Clock = 1; Clock = 0; // Write the "0"s into the '174 output_high(PIN_B1); output_low(PIN_B1); } // endfor //Data = 1; // Output the "AND" Value output_high(PIN_B2); //Clock = 1; Clock = 0; output_high(PIN_B1); output_low(PIN_B1); // Data = RS; // Output the RS Bit Value if (RS>0)output_high(PIN_B2); else output_low(PIN_B2); //Clock = 1; Clock = 0; output_high(PIN_B1); output_low(PIN_B1); for (i = 0; i < 4; i++) { // Output the Nybble if ((Nybble & 0x008) != 0) // Data = 1; // Output the High Order Bit output_high(PIN_B2); else //Data = 0; output_low(PIN_B2); //Clock = 1; Clock = 0; // Strobe the Clock output_high(PIN_B1); output_low(PIN_B1); Nybble = Nybble << 1; // Shift up Nybble for Next Byte } // endfor // Data = 1; Data = 0; // Toggle the "E" Clock Bit output_high(PIN_B2); output_low(PIN_B2); } // End LCDNybble void LCDByte(char myByte, char RS) { // Send Byte to LCD int LBDlay; LCDNybble((myByte >> 4) & 0x00F, RS); // Send High Nybble LCDNybble(myByte & 0x00F, RS); // Send Low Nybble if ((myByte < 4) && (RS == 0)) // type of instruction LBDlay = RTC + 6; else LBDlay = RTC + 2; while (LBDlay != RTC); // command to complete wait } // End LCDByte void send_c(char myByte) { // Send Byte to LCD int LBDlay; char RS = 1; LCDNybble((myByte >> 4) & 0x00F, RS); // Send High Nybble LCDNybble(myByte & 0x00F, RS); // Send Low Nybble if ((myByte < 4) && (RS == 0)) // type of instruction LBDlay = RTC + 6; else LBDlay = RTC + 2; while (LBDlay != RTC); // command to complete wait } // End send_c void SecondLine(void) { LCDByte(0xC0, 0); } // end SecondLine void Home(void) { LCDByte(0x02, 0); } // end Home void ClearLCD(void) { LCDByte(0x01, 0); } // end ClearLCD Code:
#if defined(__PCM__) #include <16F84A.h> #fuses HS,NOWDT,NOPROTECT #use delay(clock=4000000) #use rs232(baud=9600, xmit=PIN_B6, rcv=PIN_B7) #endif #include "LCDHG.C" #include <STDIO.h> #include <string.h> #define CDCLK Pin_B1 //#define LCDDAT Pin_B2 void main() { int x, y, c; x = 0x01; y = 0x01; c = 0x55; // char *c;// = "H"; // char string[20]; //c="H"; lcd_init(); lcd_gotoxy(x, y); lcd_putc("\f"); lcd_putc(0x55); while(1) { ; } // end while } |
|
|
Similar Threads | ||||
Ðề tài | Người gửi | Chuyên mục | Trả lời | Bài mới |
Về mạch nạp Microchip PICKit2 và PIC16F84A | linhbx | Bootloaders - Programmers - Debuggers - Emulators | 7 | 12-12-2006 11:39 AM |
Xin file hex bootloader của PIC16F84A | hanhluckyly | Tiny Bootloader | 1 | 18-10-2006 09:36 PM |
8 wire stepper motor | briantk_1988 | Cơ cấu chấp hành (Actuator) | 3 | 30-09-2006 11:51 PM |
One wire voi PIC16F84A | briantk_1988 | Các ngôn ngữ lập trình khác (CCS C, HT PIC,...) | 13 | 26-07-2006 08:16 PM |