shinkokarbon
Joined: 26 Apr 2020 Posts: 2
|
16F1578 rs485.c problem [Solved] |
Posted: Fri Jul 10, 2020 6:42 am |
|
|
Hi,
I tried to do communication between PIC and nRF52810 mcu with MAX485 IC . I am using rs485.c file. When i was working with pic16f1788 the communication was OK. I changed the mcu and my communication has broken. I can send data from nrf to pic but pic can't send data to nrf.
1)if i use putc function "putc(0xAA)" in main loop, i can see 8 bit output. But rs485_send_message function is not working correctly.
2) When i was working on pic16f1788, I didn't use pin_select feature. If i make comment UART pin_select, the Expect comma error occurs in rs485.c file.
3) I check the tx pin and RS485_ENABLE_PIN with ossiloscope. Enable pin is going high during the transmit operation. Tx pin is going low at beginning of the operation and going high when operation end(enable pin is going low that moment). Tx pin stay low during all the operation time, there is no data.
rs485.c
Code: |
/////////////////////////////////////////////////////////////////////////
//// RS485.c ////
//// ////
//// This file contains drivers for RS-485 communication ////
/////////////////////////////////////////////////////////////////////////
#ifndef RS485_DRIVER
#define RS485_DRIVER
#ifndef RS485_ID
#define RS485_ID 0x10 // The device's RS485 address or ID
#endif
#ifndef RS485_USE_EXT_INT
#define RS485_USE_EXT_INT FALSE // Select between external interrupt
#endif // or asynchronous serial interrupt
#if(RS485_USE_EXT_INT == FALSE)
#ifndef RS485_RX_PIN
#define RS485_RX_PIN PIN_B5 // Data receive pin
#endif
#ifndef RS485_TX_PIN
#define RS485_TX_PIN PIN_B6 // Data transmit pin
#endif
#ifndef RS485_ENABLE_PIN
#define RS485_ENABLE_PIN PIN_B4 // Controls DE pin. RX low, TX high.
#endif
#ifndef RS485_RX_ENABLE
#define RS485_RX_ENABLE PIN_B7 // Controls RE pin. Should keep low.
#endif
#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=8, long_data, errors, stream=RS485)
#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=8, parity = n, STOP=1,long_data, force_sw, multi_master, errors, stream=RS485_CD)
#if getenv("AUART")
#define RCV_OFF() {setup_uart(FALSE);}
#else
#define RCV_OFF() {setup_uart(FALSE);}
#endif
#else
#ifndef RS485_RX_PIN
#define RS485_RX_PIN PIN_B0 // Data receive pin
#endif
#ifndef RS485_TX_PIN
#define RS485_TX_PIN PIN_B3 // Data transmit pin
#endif
#ifndef RS485_ENABLE_PIN
#define RS485_ENABLE_PIN PIN_B4 // Controls DE pin. RX low, TX high.
#endif
#ifndef RS485_RX_ENABLE
#define RS485_RX_ENABLE PIN_B5 // Controls RE pin. Should keep low.
#endif
#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, errors, stream=RS485)
#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, multi_master, errors, stream=RS485_CD)
#define RCV_OFF() {disable_interrupts(INT_EXT);}
#endif
|
+++++++++++++++++++++++++++
Most of rs485.c driver code deleted.
Reason: CCS forum rule #10
10. Don't post the CCS example code or drivers, or ask for such code and drivers.
Forum rules:
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
- Forum Moderator
+++++++++++++++++++++++++++
|
|