 |
 |
| View previous topic :: View next topic |
| Author |
Message |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed Apr 13, 2016 6:30 am |
|
|
Hi,
Your description is not clear, so let me attempt to summarize:
1. If you connect to the 'hardware' UART pins, you can send data TO HyperTerminal, but you cannot receive data FROM HyperTerminal using PCM's simple program? Is that correct?
2. If you connect to some other pins (ie. a 'software' UART), you can send data TO HyperTerminal, AND you can receive data FROM HyperTerminal using PCM's simple program? Is that correct?
If the above is correct, we need to know if your USB-to-TTL converter is the *exact* one shown in the link you provided, or a similar one??? We also need to know the Vcc voltage of your PIC.
My hunch is that this is a level issue at the hardware UART Rx pin, that is not an issue with a software Rx input.
Finally, what is your compiler version number? _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9632 Location: Greensville,Ontario
|
|
Posted: Wed Apr 13, 2016 6:46 am |
|
|
I downloaded the linked datasheet...
THAT USB device is NOT going to work by simply connecting to your PIC!
The datasheet says it's an RS232 style unit , so it expects to be connected to a MAX232 or simlar RS232 device. The PIC is a 'TTL' device.
Options.
1) buy a TTL<>USB module. Up here they're $2.
2) add a MAX232 + 4 caps between PIC and the RS232-USB module.
Either of these options will work.
Jay |
|
 |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed Apr 13, 2016 7:32 am |
|
|
Hi Jay,
I suspect that link does not point to the *actual* USB-to-whatever module the OP is using, that is why I asked him the question directly. In this day and age of really cheap (mostly knock-off) Chinese USB modules, the likelihood that the OP has an honest-to-goodness FTDI USB evaluation module is really pretty slim.... _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
 |
nailuy
Joined: 21 Sep 2010 Posts: 166
|
|
Posted: Wed Apr 13, 2016 10:16 am |
|
|
Thank you to all.
First I will response in order of replies.
ezflyr:
#1 is not correct PIC in hardware UART no sending data on pin C6 so Hiper ... not receiving data and show nothing.
#2 is half correct PIC in software UART is sending data and Hiper ... show data received. Other half I search on help of CCS about if(kbhit()) and not worked, I do not know why? request help and received from PCM programmer with little program, and discover that data not sending with hardware UART. I can tell that: data send from Hiper ... is entering to PIC (I see with scope) and PIC do nothing with simple test program. I can't confirm that PIC is receiving data in buffer because if(kbhit()) never becomes true not in software not in hardware.
Also if I change software UART with the same pins as hardware is not working.
I test simple output high/low C6 and is working so output is not burned.
I use exactly this unit UB232R as is describe in picture of page no7 UB232R datasheet
Voltage powered is 5.04V and signal logic high is at 5.03V and signal logic low is 0.02V so USB converter works fine. This measurements are made on pin C7 RX.
Version compiler 5.053
now response for temtronic
If you download data sheet of chip you will see on page 31 connection directly to Microcontroller and I use only TXD and RXD pins.
Data sheet of IC:
http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232R.pdf
Data sheet of hardware converter USB->UART TTL logic
http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_UB232R.pdf
Conclusion:
This hardware used by me UB232R are using FT232R chip and is connecting directly to Microcontroller, also if I make short circuit between RX TX, Hiper Terminal show every key pressed so UB232R fork fine at 5V because J3 have jumper on position 1-2.
I look forward for your replies. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9632 Location: Greensville,Ontario
|
|
Posted: Wed Apr 13, 2016 10:39 am |
|
|
You should post your current complete code as 'something' is not correct.
As for the module, it does say TTL way in the spec. FTDI should NOT be saying 232 anywhere as '232' inplies the RS232 standard.
Somewhere in those documents they do say about inverting the data....arrgh....also you have to program the modue using a 'dll', more fun...
You might try another PIC, that one may be damaged ? Just because the software serial transmit works does NOT mean the UART is OK
Jay |
|
 |
nailuy
Joined: 21 Sep 2010 Posts: 166
|
|
Posted: Wed Apr 13, 2016 10:57 am |
|
|
Yes finally this it leads me to an outcome why?
led is not working when row "putc('H');" is enabled, when is disabled led is blinking soproblem is from heir I think not from chip or other hardware connection.
Result is the same for 1 or 4 or 8 Mhz
is working on TTL signal between USB converter and MCP.
Cod:
complete program is:
| Code: | #include <16F1788_test2.h>
void main()
{
int8 value;
while(TRUE)
{
//output_bit(PIN_C6,0);
//output_bit(PIN_C6,1);
putc('H'); // this line is bloking program when is enabled
output_bit(PIN_B5,0);
output_bit(PIN_B5,1);
// if(kbhit()) // Was a key pressed on PC keyboard ?
// {
// value = getc(); // If so, get it from UART
// putc(value); // Then send it back to terminal program
// }
}
}
////////////////////////////////////////////////////////////////////////
//#include <16F1788.h>
//#device ADC=16
//#use delay(internal=1MHz)
#include <16F1788.h>
#fuses INTRC_IO, NOWDT
#FUSES NOMCLR
#use delay(clock=8M)
//#pin_select U1TX = PIN_C6
//#pin_select U1RX = PIN_C7
#use rs232(baud=2400, UART1, ERRORS)
//#use rs232(baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=P1)
/////////////////////////////////////////////////////////////////////////////
ROM used: 45 words (0%)
Largest free fragment is 2048
RAM used: 7 (0%) at main() level
18 (1%) worst case
Stack used: 1 locations
Stack size: 16
*
0000: MOVLP 00
0001: GOTO 00A
0002: NOP
.................... #include <16F1788_test2.h>
.................... //#include <16F1788.h>
.................... //#device ADC=16
.................... //#use delay(internal=1MHz)
....................
.................... #include <16F1788.h>
.................... #device PIC16F1788
....................
.................... #list
....................
.................... #fuses INTRC_IO, NOWDT
.................... #FUSES NOMCLR
....................
.................... #use delay(clock=8M)
....................
.................... //#pin_select U1TX = PIN_C6
.................... //#pin_select U1RX = PIN_C7
....................
....................
.................... #use rs232(baud=2400, UART1, ERRORS)
0003: BTFSS 11.4
0004: GOTO 003
0005: MOVLB 03
0006: MOVWF 1A
0007: MOVLP 00
0008: MOVLB 00
0009: GOTO 022 (RETURN)
.................... //#use rs232(baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=P1)
....................
....................
.................... void main()
000A: MOVLW 72
000B: MOVLB 01
000C: MOVWF 19
000D: MOVLB 00
000E: CLRF 20
000F: MOVLB 03
0010: BSF 1F.3
0011: MOVLW 40
0012: MOVWF 1B
0013: MOVLW 03
0014: MOVWF 1C
0015: MOVLW A6
0016: MOVWF 1E
0017: MOVLW 90
0018: MOVWF 1D
0019: CLRF 0C
001A: CLRF 0D
001B: CLRF 0E
001C: MOVLB 02
001D: CLRF 12
001E: CLRF 11
.................... {
.................... int8 value;
....................
.................... while(TRUE)
.................... {
.................... //output_bit(PIN_C6,0);
.................... //output_bit(PIN_C6,1);
....................
.................... putc('H'); // Then send it back to terminal program
001F: MOVLW 48
0020: MOVLB 00
0021: GOTO 003
.................... output_bit(PIN_B5,0);
0022: MOVLB 02
0023: BCF 0D.5
0024: MOVLB 01
0025: BCF 0D.5
.................... output_bit(PIN_B5,1);
0026: MOVLB 02
0027: BSF 0D.5
0028: MOVLB 01
0029: BCF 0D.5
002A: MOVLB 02
002B: GOTO 01F
....................
....................
.................... // if(kbhit()) // Was a key pressed on PC keyboard ?
.................... // {
.................... // value = getc(); // If so, get it from UART
.................... // putc(value); // Then send it back to terminal program
.................... // }
.................... }
....................
.................... }
....................
002C: SLEEP
Configuration Fuses:
Word 1: 3F84 INTRC_IO NOWDT PUT NOMCLR NOPROTECT NOCPD BROWNOUT NOCLKOUT IESO FCMEN
Word 2: 1EFF NOWRT NOVCAP PLL_SW STVREN BORV19 NOLPBOR NODEBUG NOLVP |
I look forward for your reply.16F1788_test2.h |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9632 Location: Greensville,Ontario
|
|
Posted: Wed Apr 13, 2016 11:10 am |
|
|
When you try to send the 'H', this is where the pIC goes...
.................... #use rs232(baud=2400, UART1, ERRORS)
0003: BTFSS 11.4
0004: GOTO 003
0005: MOVLB 03
0006: MOVWF 1A
0007: MOVLP 00
0008: MOVLB 00
0009: GOTO 022 (RETURN)
BTFSS 11.4 says
test bit 4 or register 11 (PIR1) and skip if set
GOTO 3 says
loopback to 0003
It'll do this UNTIL bit 4 is a 1.
According to my copy of the 1788 manual, .4 is a pending TX interrupt...so now I'm confused as I don't see where ,if at all you've enabled ANY interrupts !
Perhaps do a 'global disable' as your compiler version may enable it ??
Hopefully someone with that PIC and close compiler version can test for you.
I'm pretty much done.
Sure be nice to KNOW what's happening though !!
Jay |
|
 |
nailuy
Joined: 21 Sep 2010 Posts: 166
|
|
Posted: Wed Apr 13, 2016 11:33 am |
|
|
I do not have any interrupts enabled or disabled in program.
How can I make global disabled interrupt?
Best regards. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9632 Location: Greensville,Ontario
|
|
Posted: Thu Apr 14, 2016 5:07 pm |
|
|
disable_interrupts(GLOBAL); // all interrupts OFF
this is covered in the CCS C manual, just press f11 while your project is open, and the manual will appear !
Jay |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|