' Ensure these port addresses are correct
#define SerInPort PORTc.7
#define SerOutPort PORTc.6
'Set pin directions
Dir SerOutPort Out
Dir SerInPort In
WAIT 1 s
DO
HSerPrint "HOLA"
HSerSend 13
WAIT 50 ms
LOOP
Last edit: Anobium 2014-02-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Did you test the code I provided? What were the results?
Please test by changing you PC software to PUTTY.EXE. You can download this. What is the result using putty.exe?
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
as the title, if I use the libraries HW for the 16F877A transmizione does not work (via RF).
Instead if I use the SW library works fine.
Solved, see https://sourceforge.net/p/gcbasic/discussion/579126/thread/19179e44/#5482 edited Anobium to link to closure posting.
Last edit: Anobium 2014-02-20
Please post your code, your pinout and any relevant information.
the TX module is connected to pin PORTC.6
The two codes that work on the same hardware.
this works fine by sending a stream clean on the RF:
CHIP 16F877A,4
CONFIG OSC=XT,WDT_OFF,PWRTE_ON,CP_OFF,DEBUG_OFF,WRT_OFF,CPD_OFF,LVP_OFF,BODEN_ON
DEFINE SendAHigh SET PORTC.6 OFF
DEFINE SendALow SET PORTC.6 ON
DEFINE RecAHigh SET PORTC.7 OFF
DEFINE RecALow SET PORTC.7 ON
Ciclo:
InitSer 1,r1200,1+WaitForStart,8,1,None,Invert
TRISA=b'000000'
TRISB=b'00000000'
TRISC=b'00011000'
TRISD=b'00000000'
TRISE=b'00000000'
PORTA=b'000000'
PORTB=b'00000000'
PORTC=b'00000000'
PORTD=b'00000000'
PORTE=b'00000000'
INTCON=b'00000000'
CVRCON=b'00000000'
CCP1CON=b'00000000'
CCP2CON=b'00000000'
ADCON0=b'00000000'
ADCON1=b'10000110'
WAIT 1 s
DO
SerPrint 1,"HOLA"
SerSend 1,13
WAIT 50 ms
LOOP
instead this stream is "dirty", or rather does not work:
CHIP 16F877A,4
CONFIG OSC=XT,WDT_OFF,PWRTE_ON,CP_OFF,DEBUG_OFF,WRT_OFF,CPD_OFF,LVP_OFF,BODEN_ON
DEFINE USART_BLOCKING TRUE
DEFINE USART_BAUD_RATE 1200
Ciclo:
TRISA=b'000000'
TRISB=b'00000000'
TRISC=b'00011000'
TRISD=b'00000000'
TRISE=b'00000000'
PORTA=b'000000'
PORTB=b'00000000'
PORTC=b'00000000'
PORTD=b'00000000'
PORTE=b'00000000'
INTCON=b'00000000'
CVRCON=b'00000000'
CCP1CON=b'00000000'
CCP2CON=b'00000000'
ADCON0=b'00000000'
ADCON1=b'10000110'
InitUSART
WAIT 1 s
DO
HSerPrint "HOLA"
HSerSend 13
WAIT 50 ms
LOOP
PD:sorry for my english
I do not have your chip type. So, I cannot test.
Try the following code. I am not sure why you are calling InitUSART.
What is your version of the compiler? How are you testing? How do you know it is 'dirty'? And, what is your oscillator config?
~~~~~
#CHIP 16F877A,4
#CONFIG OSC=XT,WDT_OFF,PWRTE_ON,CP_OFF,DEBUG_OFF,WRT_OFF,CPD_OFF,LVP_OFF,BODEN_ON
' Define the USART port
#DEFINE USART_BLOCKING TRUE
#DEFINE USART_BAUD_RATE 1200
' Ensure these port addresses are correct
#define SerInPort PORTc.7
#define SerOutPort PORTc.6
'Set pin directions
Dir SerOutPort Out
Dir SerInPort In
WAIT 1 s
DO
HSerPrint "HOLA"
HSerSend 13
WAIT 50 ms
LOOP
Last edit: Anobium 2014-02-18
always like to initialize the library usart.c
Great Cow BASIC (0.9 17/7/2011)
with a serial terminal in Gambas3 (works fine).
all in RF 433mhz.
OSC 4mhz
to be noted that even with a 16F628A there is this discrepancy (SW works, HW does not work)
SW

HW

I forgot that I have always used this code and it always worked.
as well as the HW
Did you test the code I provided? What were the results?
Please test by changing you PC software to PUTTY.EXE. You can download this. What is the result using putty.exe?
Thank you.
Gambas3 is a programming environment for basic linux (I use the distro LinuxMint Nadia Cinnamon).
same problem
I'll try on my son's PC with Hyperterminal.
See below for Google Translate of this message. :-)
So, you get the same problem using the code I provided? If, yes. Then, please test on your son's PC.
However, how are you connecting between the pic and your PC? Are you using a MAX232 or similar device?
And, I am getting the same chips as you from Microchip - they may take a day or two to get here.
:-)
Così, si ottiene lo stesso problema utilizzando il codice che ho fornito? Se, sì. Poi, si prega di verificare sul PC di tuo figlio.
Tuttavia, come vi state collegando tra la microchip e il vostro PC? Stai usando un MAX232 o un dispositivo simile?
E, io sono sempre gli stessi chip come lei da Microchip - possono prendere un giorno o due per arrivare qui.
:-)
yes, from the same mistake.
yes, use a max232
hw works with the same software library.
yes, the translator of google is my friend :P
Thank you. So, your son's computer connected to your Microchip has the same issue. 😞
It's time to get you the latest GCB code. Send me a personal email and I will send you a download link.
I sent my e-mail
tomorrow I'll try this code, bypassing the library UART GCBasic.
I took the datasheet in hand and I followed the UART procedure according Microchip for its device
CHIP 16F877A,4
CONFIG OSC=XT,WDT_OFF,PWRTE_ON,CP_OFF,DEBUG_OFF,WRT_OFF,CPD_OFF,LVP_OFF,BODEN_ON
SUB USART_Init()
TXSTA.BRGH=0
TXSTA.SYNC=0
SPBRG=51
RCSTA.SPEN=1
RCSTA.CREN=1
TXSTA.TXEN=1
END SUB
SUB USART_TX(Caracter AS BYTE)
WAIT UNTIL TXIF=1
TXREG=Caracter
END SUB
SUB USART_RX()
DIM Caracter_RX AS BYTE
WAIT UNTIL RCIF=0|OERR=0
Caracter_RX= RCREG
IF OERR=1 THEN
RCSTA.CREN=0
RCSTA.CREN=1
END IF
USART_RX=Caracter
END SUB
SUB USART_Print(Frase AS String)
DIM Envia_frase AS INTEGER
DIM Len_Print
Len_Print=Frase(0)
FOR Envia_frase=1 TO Len_Print
USART_TX(Frase(Envia_frase))
WAIT 1 ms
NEXT
END SUB
Ciclo:
TRISA=b'000000'
TRISB=b'00000000'
TRISC=b'10011000'
TRISD=b'00000000'
TRISE=b'00000000'
PORTA=b'000000'
PORTB=b'00000000'
PORTC=b'00000000'
PORTD=b'00000000'
PORTE=b'00000000'
INTCON=b'00000000'
CVRCON=b'00000000'
CCP1CON=b'00000000'
CCP2CON=b'00000000'
ADCON0=b'00000000'
ADCON1=b'10000110'
USART_Init()
WAIT 1 s
DO
USART_TX 72
WAIT 1 ms
USART_TX 79
WAIT 1 ms
USART_TX 76
WAIT 1 ms
USART_TX 65
WAIT 1 ms
USART_TX 13
WAIT 50 ms
LOOP
Last edit: alejandro1957 2014-02-19
I have sent you the Sept 2013 code for GCB.
Please try first and let us know the results. Please backup your folders and config before updating.
If the update fails then try your new method.
Anobium
all ok.
now works with the code posted and stop bits set to 1 in the receiving program.
to revise this sub
SUB USART_Print(Frase AS String)
DIM Envia_frase AS INTEGER
DIM Len_Print
Len_Print=Frase(0)
FOR Envia_frase=1 TO Len_Print
USART_TX(Frase(Envia_frase))
WAIT 1 ms
NEXT
END SUB
What fixed it? New code or your function?
:-)
now also works HW library.
but the code posted by me is less "heavy" and it serves my purpose.
GCBasic is always the best.
As you put SOLVED?
Case solved. Update the code. You have more functionality also - see the new helpfile.
:-)
how do I write as solved??
Se fossi Sherlock Holmes, il famoso detective inglese, direi 'caso chiuso'. Ma, io non sono. :-)
Raccomando il termine 'risolto'.
'Risolto. Aggiornamento per ultimo codice GCB ha risolto il problema '