Тёмный
No video :(

Serial UART 🔴 PIC Microcontroller Programming Tutorial #7 MPLAB in C 

Binder Tronics
Подписаться 5 тыс.
Просмотров 28 тыс.
50% 1

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 56   
@BinderTronics
@BinderTronics 4 года назад
Full playlist on the PIC microcontroller Programming ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-KSI6fzOPVz0.html If there is anything you would like to see let me know.
@vantoanle8257
@vantoanle8257 3 года назад
as I know, Input TRIS.. =1, output TRIS... = 0. TRISCbits.RC6 and RC7 are TX and RX. RC6 is transferred, RC7 receives mean RC6 output and RC7 input. Why you use both of them for input " RC6 RC7 = 1 "
@BinderTronics
@BinderTronics 3 года назад
@@vantoanle8257 0:40
@vantoanle8257
@vantoanle8257 3 года назад
@@BinderTronics thank you so much, i dont see that.But when reading PIC16F887 datasheet, I realized it doesn't have that line, so with pic16f887 I also configure it like you?
@BinderTronics
@BinderTronics 3 года назад
@@vantoanle8257 12.1.1.1 Note 1. No need to alter the TRIS register.
@alexapetri7200
@alexapetri7200 4 года назад
On a PIC18F45k22 I also had to set ANSELCbits.ANSC7 = 0 and ANSELCbits.ANSC6 = 0 . And be careful at the register names because you have two UARTS (TXSTA1 or TXSTA2, for example). In case someone needs this, ofc, not Binder Tronics. Thank you, it's working!
@pengpleb
@pengpleb 4 года назад
Thank you so much, finally got this damn UART to work. However, I had to do some changes under MPLAB X IDE v5.30 and XC8 v2.10: - #include - void __interrupt() high_isr(void); - void __interrupt(low_priority) low_isr(void); (Same signature when implementing the interrupts at the end of the file).
@BinderTronics
@BinderTronics 4 года назад
Thanx for the update. Probably too get the compiler stander with other multi interrupt PICs. Added a comment on Tutorial #5 - Interrupts ( ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-MiPxVmj_nHI.html ) if you want to claim credit.
@AlbertRei3424
@AlbertRei3424 3 года назад
@@BinderTronics I think it is no longer necessary to include : #include
@BinderTronics
@BinderTronics 3 года назад
@paul The header is there for reference. The compiler will drop is if it is included somewhere else.
@AlbertRei3424
@AlbertRei3424 3 года назад
@@BinderTronics I have never included the header and I have no issue for now
@tomasparrado873
@tomasparrado873 4 года назад
I have a suggestion/request: Uart communication with the CRC peripheral. I'm using a PIC18F26Q10 to control stepper motors through TMC2209 where the more advanced features can be accessed through serial communication with CRC. Its not the only chip (tends to be high power/noisy chips) that wants or has this additional check. They have an example in the datasheet using code, but a lot of the PIC18F have CRC hardware built in. Ben Eater did a fantastic tutorial on how CRC works ("How do CRCs work?") but an example 'irl' would be awesome (for me at least). Great tutorial set, more on any peripheral would be great. How about USB or the new ADC2? Subscribed
@BinderTronics
@BinderTronics 4 года назад
If noise is a issue use a RS232 to RS422 connection and keep the RS232 lines a short as possible. This eliminates 99% of the noise problem but this not always piratical. The industry approach to CRC is get someones open souce library for what ever protocol you are working with since most of it is standardized or someone in the company has already written one. I will have a look into it though. I am currently working on a CDC USB device video but I have no idea how long it will take. I will put ADC2 on the list. I am prioritizing getting SPI out the door at the moment.
@tomasparrado873
@tomasparrado873 4 года назад
@@BinderTronics Good suggestion to eliminate noise. In my case the hardware I'm using doesn't give you another choice except uart with CRC bits. Ordinarily I'd be happy to get a C library, and do it in firmware but it seems a shame when it's a built in peripheral. I'll give the MPLAB Code Configurator a go and hopefully pick it apart. A USB serial is a great idea as is SPI, I think a lot more people will find it useful. Capacitive touch / mTouch / touch buttons might be another video with wider appeal (and fairly easy too).
@gokulg9541
@gokulg9541 4 года назад
Well explained!
@erictutkowski849
@erictutkowski849 4 года назад
Really great channel! I've been giving your videos a watch and they help out so much. I'm trying to get UART working but I need some sort of display or terminal for it to send the transmission to and I'm not sure how to do that :/. Got any tips for setting up putty with it?
@BinderTronics
@BinderTronics 4 года назад
Going to assume you got a CH340 or FTDI usb-to-serial board. Don't get a prolific based one... piece of crap. Otherwise follow this guide pbxbook.com/voip/sputty.html there are linux and mac guides there as well.
@erictutkowski849
@erictutkowski849 4 года назад
@@BinderTronics not sure if I'm using what you stated above, But as for the chip it's a bit more complex I believe. I've been using a p32mx795f512l and while the ports are different from yours in many ways, your videos have been a great reference to use alongside the manual. I'll definitely check out the link for setting up putty though, thanks so much!
@erictutkowski849
@erictutkowski849 4 года назад
@@BinderTronics Ok! I think I have the terminal working correctly now. Just have to fix up my code and make it run :)
@erictutkowski849
@erictutkowski849 4 года назад
@@BinderTronics Finally got code working! For some reason my Serial to USB drivers weren't installed, which caused the brunt of my issues. Thanks a million for the putty set up though :)
@prasanthchigurupatii
@prasanthchigurupatii Год назад
Loved
@stewartmclaughlin1199
@stewartmclaughlin1199 4 года назад
Mooi so! Weet jy hoe om groter datatipes soos float oor die lyne te stuur?
@BinderTronics
@BinderTronics 4 года назад
Het 'n stuck kode wat dit doen in die video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-yFvJXxaY4O0.html
@stewartmclaughlin1199
@stewartmclaughlin1199 4 года назад
@@BinderTronics Wonderlik, baie dankie!
@meherkhan7456
@meherkhan7456 3 года назад
hello, I'm quite new to micro controller. I cant understand the start bit and the end bit of a signal. Could you please make it a bit clear. love your videos & thanks in advance.
@BinderTronics
@BinderTronics 3 года назад
Frame format: Idle | start | data | parity | stop idle: digital high start : 1 bit width low data: 5-9 data bits. parity: 1 or 0 of 1 bit width stop : 1 or 2 high bit widths 1 bit width is the baud rate. Since this is a Asynchronous hardware protocol, each bit has a set time it can be high or low. This also means that the sending and receiving end needs to be configured identical for it to work. So a start bit is 1 bit width low. The stop bits are 1 or 2 bit widths at the end of a frame. In most cases for UART you don't need to concern yourself with the how the frame is generated. All you need to do is load the transmit register (TXREG in this case) and the frame is generated for you. All you need to concern yourself with is the data width, parity type, number of stop bits and the baud rate in the setup. ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf 19.4 Frame Formats
@meherkhan7456
@meherkhan7456 3 года назад
Thanks a lot
@gokulg9541
@gokulg9541 4 года назад
How will you receive from the UART2? RCREG2?! . Why did you use the RCREG instead of RCREG1 for UART1?
@BinderTronics
@BinderTronics 4 года назад
Going to assume your PIC microcontroller has 2 or more UART module on it. I use RCREG cause that is the naming of the C structure for that register on the PIC microcontroller I am using. Since there is only one UART on the PIC it does not need the number at the end of the naming. In the case where there is more than one module that have the same register structure (doing the same thing) the naming will be registerX (UARTx). So if you are working with UART1. All register associated with UART1 will be followed by a 1 thus the RCREG1 in your case.
@jasmenelee
@jasmenelee 2 года назад
Can u please make video on PIC18F27K42 on UART asynchronous receiver?
@BinderTronics
@BinderTronics 2 года назад
What is unclear in the datasheet?
@adrianV68
@adrianV68 5 лет назад
Would it change the procedure a lot if we wanted to establish communication with a bluetooth module?
@BinderTronics
@BinderTronics 5 лет назад
No, just need to change the baud to match the module and create a fifo buffer for the received data. Also may need to create some form of AT parser. You will probably run into lack memory on the 18f4520 before anything else. If you are using another PIC I would suggest using Microchip Code Configurator plug-in to setup the UART.
@adrianV68
@adrianV68 5 лет назад
Thanks
@AlbertRei3424
@AlbertRei3424 3 года назад
How did you connect the PIC to the PC ? ¨Pickit3 ? It supports UART?
@BinderTronics
@BinderTronics 3 года назад
Watch the Schematic section again. I use a FTDI usb to serial.
@shite9678
@shite9678 2 года назад
I keep getting error conflicting data types for uart_send... any idea?
@BinderTronics
@BinderTronics 2 года назад
uint8_t *data; uart_send(data); uint8_t data; uart_send(&data);
@shite9678
@shite9678 2 года назад
Thanks for the response, I've got it all worked out now. Using the PIC18F45K22 like stated in comments below I have multiple registers ex. "TXSTA1" and I'm on C99 which has some syntax differences ex. Interrupts. I'm controlling basic GPIO functions through UART atm and now working on reading i2c Honeywell temp and humidity sensor. Thanks for all you do bud and look forward to more videos.
@nitinkamble6399
@nitinkamble6399 5 лет назад
hi sir, i want lora ra-02 module interface with pic microcontroller, so please help
@BinderTronics
@BinderTronics 5 лет назад
Only familiar with Lora RF1276-868RS232 witch is just straight RS232 interface. Have not touched the ra-02 modules.
@diyelectronics3158
@diyelectronics3158 4 года назад
Header file error occurs usually. .why
@BinderTronics
@BinderTronics 4 года назад
#include for newer compilers. Otherwise going to need more context.
@diyelectronics3158
@diyelectronics3158 4 года назад
@@BinderTronics how can I add header files as we do in arduino. ..any link. .??
@BinderTronics
@BinderTronics 4 года назад
@@diyelectronics3158 Project Tree > right click > Add Existing Item ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OQ6hZzkvXMw.html same place as adding new files
@Tortuga2321
@Tortuga2321 4 года назад
SPBRGH = (gen_reg & 0xFF00) >> 8; SPBRG = gen_reg & 0x00FF; teacher why did you do this ?I did not understand. Is to ignore high byte
@BinderTronics
@BinderTronics 4 года назад
SPBRGH and SPBRG are both 8 bits wide registers. gen_reg is 16 bits wide. SPBRGH is equal to the upper 8 bits of gen_reg. SPBRG is equal to the lower 8 bits of gen_reg. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-jiDUifbxC6U.html
@Tortuga2321
@Tortuga2321 4 года назад
@@BinderTronics thank you so much. So my teacher, what do TXREG and RXREG do?
@BinderTronics
@BinderTronics 4 года назад
TXREG = data to send. RXREG = data received. datasheet section 18.2.1 and 18.2.2
@mba2ceo
@mba2ceo Год назад
How hardware connect ?
@BinderTronics
@BinderTronics Год назад
be specific
@mba2ceo
@mba2ceo Год назад
@@BinderTronics How do U connect the BOARD to see the TERMINAL ?
@BinderTronics
@BinderTronics Год назад
Schematic section. Terminal program Putty
Далее
娜美这是在浪费食物 #路飞#海贼王
00:20
WELCOME TO THE FAMILY, MOE! (Brawl Stars Animation)
00:40
PIC USART Tutorial - PIC Microcontrollers - PIC16F877a
24:33
Programming the PIC16F84A in C with MPLAB X
14:19
Просмотров 57 тыс.
Understanding UART
6:11
Просмотров 183 тыс.
娜美这是在浪费食物 #路飞#海贼王
00:20