PDA

View Full Version : HSER Problems



Kaldurenik
- 24th September 2007, 09:26
Good day every one!
I have a problem (that none of my teachers even can solve) so i was hopeing that some one here can help me!
I use a PIC 16F877A and i want it to take / recive and send information. Basicly im just doing small programs trying to see how things work right now.
Any how All work good but one thing!
It only recive 3 bytes! (even if i transmit 20)

This is the test program code:

DEFINE LOADER_USED 1

DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 2400

DEFINE OSC 4

Char VAR BYTE[9]

main:
HSERIN [char]
PAUSE 100
HSEROUT [char]
RCSTA.4 = 0
RCSTA.4 = 1
GOTO main

END

basicly im transmiting this (15bytes):
Hej på dig pic

And recive this (3bytes):
Hej


Thanks in advance!

mister_e
- 24th September 2007, 16:06
LMAO! and they're teacher? Really???

First of all i would suggest you remove the PAUSE 100 and use something like
HSERIN [STR char]
HSEROUT [STR char]

refer to HSERIN/HSEROUT section of the manual. the above may miss something in.


You can also try this one.. simple...


DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 25 ' 2400 Baud @ 4MHz, 0.17%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically

Main var byte

Main:
Hserin [Char]
Hserout[Char]
GOTO Main

Kaldurenik
- 25th September 2007, 07:21
Good day. Thanks alot! Yes that person is a teacher. Any how i will stick around on this website and if i have more questions im sure i will get more good answares! Thanks alot again!

mister_e
- 25th September 2007, 22:12
;) so now you really want to learn french, move 'round Montreal and be one of my student ??? :D

You're welcome, good luck, and don't give up!

pssst: suggest to your teacher to come here as well :D

Kaldurenik
- 26th September 2007, 09:31
Hehe ;) Maybe if i had time and money i could come and learn more about PIC but im poor and dont have alot of time :(.
And no i dont ever give up!

Hehe dont know if i dare to ask him if he wants to ;) (my teacher that is).

Thanks again!

Kaldurenik
- 1st October 2007, 09:13
Good day every one!

I have a new problem now ;).
I want a led to be on for 5sec. How ever pause and HSER dont work together. Any sugestions?

This is the program:

DEFINE LOADER_USED 1

DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 2400

DEFINE OSC 4

Char VAR BYTE
LEDB var PORTD.1
LEDG var PORTD.2
LEDR VAR PORTD.4

main:
GOSUB standby
LOW LEDB
HSEROUT [STR char \1]
HIGH LEDG
PAUSE 5000
LOW LEDG
RCSTA.4 = 0
RCSTA.4 = 1
GOTO main

Standby:
High ledb
HSERIN [str char \1]
RETURN

Error:
END

mister_e
- 1st October 2007, 16:54
use HSERIN [CHAR] and HSEROUT[CHAR] may solve few things. And you should DEFINE RCSTA as well... even if by default it's 2400 baud. Not sure how DEFINE LOADER_USED affect the whole thing.

try...


DEFINE OSC 4
DEFINE LOADER_USED 1

DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 25 ' 2400 Baud @ 4MHz, 0.17%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically


Char VAR BYTE
LEDB var PORTD.1
LEDG var PORTD.2
LEDR VAR PORTD.4

main:
GOSUB standby
LOW LEDB
HSEROUT [Char]
HIGH LEDG
PAUSE 5000
LOW LEDG
GOTO main

Standby:
High ledb
HSERIN [Char]
RETURN

Error:
END

What do you really want to do with the above? Learn something, or doing something useful?

Kaldurenik
- 2nd October 2007, 06:39
Learn and do something useful. Im doing a school project and its going to be a thing for school also. Every one at our school have "school cards" im are going to do a hmm... You know where you run around in a forest looking for things on a map? Well im are doing the "checkpoints" there. I want so that you only have to use the school card and you will get the information automaticly to the main computer (so you can see time betwen each checkpoint. And time from start to goal.

Edit: So this is what i want to learn:
How to get better at pic, electronics, security and RfID.

And i want to have fun also ofc :)

Kaldurenik
- 8th October 2007, 12:41
Also this dont work... I cant use pause, sleep, wait or any function like that because it makes the pic laugh at me :(

Kaldurenik
- 15th October 2007, 08:33
bump and /pray :(