12Lapointep
Joined: 04 Aug 2015 Posts: 16 Location: United States
|
RS232 CTS line |
Posted: Thu Aug 20, 2015 9:26 am |
|
|
Hey all, I am using a PIC18F67J94 with MPLAB X IDE v2.35. I am having some issues and concerns with my CTS line when I test the software and hardware. I have a buffer with 256 bytes in size. But the CTS line seems to be triggering LOW after every single character that enters the buffer. Here is the picture of my oscilloscope after I received a '1' in ASCII characters. Technically, the buffer would get full when there are 256 characters in the buffer and the CTS line would get triggered until it is clear to send. My code is shown below:
Oscilloscope picture:
how to take a screenshot on a pc
Code: | //Pre-processor directives
#include <18F67J94.h>
#include <SerialComms.h>
#include <stdlib.h>
#include <stdio.h>
#define USE_TX_ISR
#define RCV_BUF 256
#fuses NOPROTECT
#fuses FRC_PLL
#fuses PLL8X
#fuses NOWDT
#use delay (clock=64000000)
#pin_select U3RX=PIN_D4
#pin_select U3TX=PIN_D1
// RS-232 Serial Port setup
#USE RS232(BAUD=115200, UART3, BITS=8, PARITY=N, ERRORS, RCV=PIN_D4, XMIT=PIN_D1, RECEIVE_BUFFER=RCV_BUF, TRANSMIT_BUFFER=256, CTS=RS232_RTS3, RTS=RS232_CTS3, FLOW_CONTROL_MODE, TXISR, STREAM=RS232)
#SEPARATE
void PowerUpInit(void)
{
// Set I/O bits low.
REG_PORTA = 0x00;
REG_PORTB = 0x00;
REG_PORTC = 0x00;
REG_PORTD = 0x00;
REG_PORTE = 0x00;
REG_PORTF = 0x00;
REG_PORTG = 0x00;
// Set I/O pin directions (input/output).
set_tris_a(PORT_A_DIR);
set_tris_b(PORT_B_DIR);
set_tris_c(PORT_C_DIR);
set_tris_d(PORT_D_DIR);
set_tris_e(PORT_E_DIR);
set_tris_f(PORT_F_DIR);
set_tris_g(PORT_G_DIR);
// Oscillator setup and clock frequency setup
setup_oscillator(OSC_8MHZ|OSC_INTRC_PLL);
enable_interrupts(GLOBAL);
}
int Main(void)
{
delay_ms(100);
PowerUpInit();
delay_ms(100);
char c;
fprintf(RS232, "\r\nSerial_Comms_Project.C\r\n\n");
while(1)
{
delay_ms(1);
if(kbhit(RS232))
{
output_toggle(YEL_LED);
c = fgetc();
fputc(c);
if(c == '\r')
fputc('\n');
else if(c == '\b')
{
fputc(' ');
fputc(c);
}
}
}
} |
Do not hesitate to comment if you have any pertinent information about CTS or my code.
Thanks! |
|