Hi nodCarlos
Do you have anything working ?
Can you blink an LED ?
Have you got the correct defines for registers and clock speeds ?
What crystal/clock source are you using are you using ? It seems like 20 MHz external ocscillator/crystal according to your HSER defines , not so ?
In order for many here to help you, you may consider posting your whole code examples showing things like clock speeds and so on.
Try something simple first.....NO ADC or anything apart from serial data sending here!
Here is some code you can try for a start.
Code:
'Port IO directions and presets for port pins begin here
'TRISX = %76543210 << tris bit order numbering
'TRISA = %11111111 'All pins are outputs
'// Define port pins as inputs and outputs ...
TRISA = %00000000 'example only - TRISB = %00001111 ;Make B4-B7 outputs, B0-B3 inputs,
TRISB = %11111111 'for 4x4 keypad all input
TRISC = %10010000 'NOTICE port 7 here for HSERIN !! And port 6 for HSEROUT
TRISD = %00000000
TRISE.0 = 0
TRISE.1 = 0
TRISE.2 = 0
'End of Port IO directions and presets for port pins begin here
'Variables being here
Y var BYTE 'decalre Y as byte
Y=123 'set Y=123
'HSEROUT defines
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 129 ' 9600 Baud @ 20MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
' Check port settings PORTC.6 = TX and PORTC.7 = RX
' For PIC to PIC TX to RX C.6 to C.7 and visa versa
' Don't forget TRISC=%10000000
'HSEROUT USART defines and register settings end here
main:
"HSEROUT line begins here
HSEROUT ["here is the total ",dec Y,$0d,$0a] 'send result to pc com port
'this line sends the DECimal for of Y to MAX
'HSEROUT line ends here
'UNCOMMENT if you want to use SEROUT to do the same thing
'*******************************************
'this lines works perfectly to send data
'*******************************************
'SEND data to MAX to PC
'SEROUT PORTC.3,T9600,["the received value is ", Y,10,13]
'SEROUT line ends here
'UNCOMMENT these lines if you're using an LCD
' pause 1000
' LCDOUT $fe,1
' LCDOUT "The total is",dec Y
'End of LCDOUT line
goto main
END
Please note the code above assumes you are using a 20 MHz clock,you will need to add the necessary lines at the beginning of your code to suit the PIC you are using. I have commented the code to help you out as much as possible.
You will also notice the variable Y is set to the value 123..only change this after you are successfully seeing data in your serial tool window on the PC.
Hope this helps
Dennis
Bookmarks