Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Please any help! PIC serial interface

Status
Not open for further replies.

dbsjro

Newbie level 5
Joined
Aug 22, 2009
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,336
pic to pic serial

Hello everyone.

I manage to send, lets say for example the character "N" (or enything i don't care) from PC but i can't make my microcontroller (pic16f628) do anything.

It just can't compare the character "N" with something in the code
in case i sent "something else" do nothin
in case i sent "N" do what i want

Thnx in advance
 

pic serial interface

Nobody has ever used getc(); or USART from a PIC?
 

pic serial interfacing

I think that no one understands what your problem is. It would help if you posted some code to show what you are doing, and people can comment on what is wrong,
 

getc pic

Yes you are probable right
i wanna read a string and when it is the desired one to do something

Code:
#include <16F628.h>
#fuses INTRC_IO, NOLVP, NOWDT, PUT, BROWNOUT
#use delay(clock=4000000)
#byte PORTB = 0x06
#byte PORTA = 0x05
#use fast_io(A)
#use fast_io(B)
#USE RS232(BAUD=9600, XMIT=PIN_B2, RCV=PIN_B1, uart1, parity=n, bits=8, stop=1,)

void main(void) {
char a=0;
set_tris_b(0b00000110);
set_tris_a(0x11);

   while(true) {
   
   a=getc();


   if ( 'a' == a) {
   output_high (pin_b6);
   output_low (pin_b7);}
   else {
   output_high (pin_b7);
   output_low (pin_b6);}

}}
Hope you understand what i m trying to do
 

pic seri yazıcı

if ( 'a' == a)

I think you are reversing the syntax. It should be:
Code:
 if(a=='a')
Also, take care that 'a' is different from 'A'.
I mean comparison in "if-statement" is case-sensitive.

I hope this helps.
 

troubleshoot serial interface

seadolphine2000 said:
I think you are reversing the syntax. It should be:
Code:
 if(a=='a')
Not really. It is more usual to write
Code:
 if(a=='a')
but the result is the same if you write it the other way around. Also note that writing
Code:
if('a'==a)
guards against a common bug. If you accidentally write a single equals sign instead of 2 signs togethr, ie
Code:
 if(a='a')
then you get code that doesn't do what you want but is valid, and the error can be hard to spot. Make the same mistake with the order reversed, ie
Code:
 if('a'=a)
and it won't compile. So the syntax dbsjro uses highlights your error immediately and is thus safer.

Also, take care that 'a' is different from 'A'.
True. Good practise is to convert both sides to upper case before making the comparison.
 

Re: pic to pic serial

tryy this one www.twitter.com/VEATechs.Follow them for any ideas . It really works!!!

dbsjro said:
Hello everyone.

I manage to send, lets say for example the character "N" (or enything i don't care) from PC but i can't make my microcontroller (pic16f628) do anything.

It just can't compare the character "N" with something in the code
in case i sent "something else" do nothin
in case i sent "N" do what i want

Thnx in advance
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top