thanks steve for helping me on the way again.
i figured it out with your sample code and i'm back on track.
thx again
thanks steve for helping me on the way again.
i figured it out with your sample code and i'm back on track.
thx again
Oh I clapped my hands when I found this, thought i had got a working example of hserout...
didnt work for me.........
I changed it a little as I like to run at OSC 48 etc, and dont use a boot loader, and didnt need hserin, so just did a hserout and a 1 second pause to see if i could receive at the PC end, but I get the wrong chars, usually =_Y=_Y etc repeated
Code:' Baudrate : 9600 Bauds ' Method : Polling USART interrupts flags ' Pic Definition ' ============== ' Using PIC 18F2550 @ 48 MHZ ' DEFINE OSC 48 clear ADCON1 = %00001111 ' Hardware configuration ' ====================== TRISC = %10000000 ' PORTC.7 is the RX input ' PORTC.6 is the TX output ' Serial communication definition ' =============================== ' Using internal USART and MAX232 to interface to PC ' DEFINE HSER_RCSTA 90h ' enable serial port, ' enable continuous receive ' DEFINE HSER_TXSTA 20h ' enable transmit, ' BRGH=1 ' DEFINE HSER_BAUD 9600 DEFINE HSER_CLROERR 1 ' automatic clear overrun error ' Alias definition ' ================ RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty) TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full) ' Variable definition ' =================== SerialData var byte ' Hardware initialisation ' ======================= pause 10 ' safe start-up delay Main: pause 1000 toggle portb.0 hserout [65,10,13] ' send it goto main
Also portC.1 goes high ?
led flashes 1 second on and 1 second off so i'd say cpudiv etc is right.
Have i done anything obviously wrong?
ok double checked the hardware on the pc side, its a pl2303/usb cable, as my laptop nhas no com: ports.
if i short pins 2/3 then i see what i type, so the hardware to that point is working.
i then plug this into my dev board, which has a max232 on it, this is connected to the PIC via a dip switch on rc6/rc7. if i disconnect it from the pic with the switches and then short these, i see what i type again, so the max 232 is working both ways...
I flip the switches and reconnect to the pic, and i get garbage on screen, about once a second, and the chr counter advances by 3, so its almost right, but not quite........![]()
Below the EUSART setting for 48 Mhz as per Mr E pic calculator.
Al.DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 225 ' 9600 Baud @ 48MHz, 0,0%
SPBRGH = 4
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
All progress began with an idea
I did have a look at the Mister_e tool, but it said it needed a dll i didnt have.
Also still same, but then i found baudcon.4=1.......bingo! (Ok a friend pointed to it!)
Seems i needed my bits the other way up...
Other issue still remains, portc.1=high, but i see nothing in the above to cause it?
No doubt its a quirk of using the Hw instead of the software routine.
I could always consider it a power light....
Hi f_lez,
check out post 10 in this thread. I had that problem too, this fixed it.
http://www.picbasic.co.uk/forum/showthread.php?t=4994
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks