desgin
Full Member level 1
- Joined
- Apr 7, 2017
- Messages
- 96
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 813
... if anyone could give me the code for master and slave modules for .. PICs.
Might be a typo on the PIC16F477A (no such device), but if both devices have UARTS, it would be WAY simpler to get the 2 parts to talk to each other.
I am first trying with UART but in that also nothing is coming
Then finally i want to use I2C protocol only
If you can't get a UART to work then, as others have said, going to a I2C solution is only going to make things worse.
You are not helping yourself with vague statements like "nothing is coming".
With the PIC18F4550, can you connect the Tx and Rx pins for the UART together and have the UART receive what ever character you send? If you can then try the same thing with whatever the PIC16F device is that you have. Once you can do that with each device separately, then try to connect them together. At least with that approach you can tell where the problem might be.
Also can you show us the code you have written as the answer will most likely be there, or with the way you are setting up the device with the config settings.
Susan
You are choosing the most painful path.
Serial communications are somewhat easiest to work and easiest to debug.
unsigned char data;
void main(void)
{
ADCON1 = 0x0F;
lcd_on();
OSCCON = 0x72;
uart_On();
while(1)
{
data='d';
transmitted_data(data);
}
}
unsigned char data;
void main(void)
{
ADCON1 = 0x0F;
lcd_on();
OSCCON = 0x72;
uart_On();
while(1)
{
data = received_data();
lcd_data(data);
}
}
Hi,
If both devices have separate power supplies, then don´t connect VCC.
Just: RxD-TxD, TxD-RxD, GND-GND.
**
You need to ensure that baudrates match. And you need to ensure that signal voltage levels match.
Klaus
unsigned char data;
void main(void)
{
ADCON1 = 0x0F;
lcd_on();
OSCCON = 0x72;
uart_On();
while(1)
{
data='d';
transmitted_data(data);
Delay_ms(100); // <----------- add a delay !
}
}
hello,
if you send to quickly data, UART will hang because OVERRUN or FRAME error .. on Receiver side !
Add a delay beetwen each invoiceon Emitter side..
Code:unsigned char data; void main(void) { ADCON1 = 0x0F; lcd_on(); OSCCON = 0x72; uart_On(); while(1) { data='d'; transmitted_data(data); Delay_ms(100); // <----------- add a delay ! } }
on receiver :
Where is LCD init ?
You must manage also the position XY on LCD , before writtin data
and after receiving 16 times the char , put again the LCD cursor at the begining of LCD position
How to ensure that
1. baudrates are matching ?
In program i am giving 9600 baud rate ( in both UART source file), its same for both.
You can echoes the received byte from transitter, or temporarily insert into the receiver's side a routine to send a byte back to the transmitter some character to verify that at least if the baudrate is configured correctly or not.
You have not yet shown the part of the code that initializes the LCD and the UART. It were expected some function with the prefix Init_xxx; or are you just assuming that it is already being configured, like using some default value provided by the compiler ?
I already post the code
I have initialized LCD and UART both.
How to start with I2C communication between 2 Microcontroller ?
hello,
if you allways swap between UART or I2C link.. difficult to follow
and be more serious :
post all your project ( Config bit + source) + schematic
Then
you maybe will get usable support.
So you have verified that that the Master is sending data already via serial tool? Just want the make sure.
Can the Slave put anything on the LCD? Try putting something on the screen before entering the while loop. (Comment out the LCD logic in the loop to make sure it does not corrupt the test.) Just to make sure that the LCD is working.
Do you have an led? Try flashing it. Then make it flash when you send a specific character. Just to make sure you can receive data.
The delay on the transmission, lets make the that stupidly large. Just cause if your gonna make a delay go big! (Within reason! 1-2sec)
It is worth noting that you appear to be using the internal clock. This could be a problem. If you have an external crystal, I would try adding it to both boards and reconfiguring it to use it. UART uses a baud which embeds a clock of sorts in the signal. This is agreed on ahead of time and both sides must match. If the clock sources are a wrong there can be a drift in sampling. UART is somewhat forgiving, but only up to a certain point. There is also a small amount of syncing.
Note you will not need the external crystal with i2c, since the master sends the clock to sample off of with the data. Just need to make sure that both can talk at the selected CPU, which is not a problem here since they are the same microcontroller.
For i2c,
Master and slave both projects will be different folders, right ?
And first slave project has to loaded in micro controller. correct ?
You are asking steps that are quite trivial in microcontrollers programming field; Before making a project with communication between two systems ( which would require some debugging skill ) I would recommend doing something a little bit more simple, starting from a blinking led, latter sending data to PC and so on. Answering the above specific question, yes, if transmitter and receiver do different stuffs, you have different codes and you should create projects in sepparated files.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?