Running demo on Arduino Mega2560 Topic is solved

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderators: utzig, tfAteba

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

Running demo on Arduino Mega2560  Topic is solved

Postby tfAteba » Tue Sep 13, 2016 7:47 am

Hi all,

I'm working with ChibiOS 16.1.5 on Arduino Mega2560.
I want to know if the demo for the Arduino Mega1280 is supposed to work with Arduino Mega2560.
Here is what I did to make it work for my target but I can't make it work!

In the Makefile:
MCU = atmega1280 ==> MCU = atmega2560
AVRDUDE_PROGRAMMER = arduino ==> AVRDUDE_PROGRAMMER = wiring
AVRDUDE_PORT = /dev/tty.usbserial-A7004IPU ==> AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex ==> AVRDUDE_WRITE_FLASH = -D -U flash:w:$(TARGET).hex

It compile and I can flash the ch.hex to the board but the result of the TestThread(&SD1); is unreadable caracters.

I carefully check the baud rate when connected to the serial port. 38400b/s.

I also play with the CH_CFG_ST_FREQUENCY macro but the result is still the same.

Is there any things else to configure to resolve the problem?
regards,

Theo.

utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 20 times
Contact:

Re: Running demo on Arduino Mega2560

Postby utzig » Tue Sep 13, 2016 12:26 pm

Hi Theodore,

As far as I remember changing the MCU should be sufficient. Are the unreadable characters always the same or lots of different unreadable characters?

If it is using the tickless timer I suggested trying the non-tickless.

The only relevant changes from 1280 to 2560 are the size of the PC which seems to be correctly handled on chcore.h. Also have you tried with latest SVN head?

Cheers,
Fabio Utzig

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

Re: Running demo on Arduino Mega2560

Postby tfAteba » Tue Sep 13, 2016 9:52 pm

Hi Utzig,

Sorry that be so long to respond.

You are right, the only thing we need to do is to change the MCU to use the AVR demo for the Arduino Mega.

Finally I made test with a trunk version and also with 16.1.5 version and every thing was ok. ;)

So I carefully check the changes I have made to understand why it din't work yesterday.
In halconf.h I have change the default baudrate to 115200 instead of 38400 and I got that output for the thread test:

��������*uB������������*�����9������ɵ*uR������驷���6�����њ����ږ,A*��������[њ����)A�Ҙ,�����Sʐ#��������[隂����A����#����0�ѵ�Ŵ-VN��Ie�����+Ր%��8Cy���šIu�����+��*kݚ��:ݮ���� Bٱ�ݺ/����Ue������

ݡN��鴭�ݐ��ōA���Ѫ��ժ��պ��麍�ɺ��ɺ��ɺ��ɲ��ٲ��ٲ��ٲ��ٶ��ٶ��Ѫ��Ѫ�#Aٶ��
ų)ž$����՜���/3Ŵ�ݮ�^ъ�� Bͻ-Kq�Rm���e��ٲ��ٲ��ٲ��ٶ��Ѷ��Ѫ��Ѫ��Ѫ��Ѫ��ժ��պ��ɺ��ɺ��ɺ��ɲ����� Rճų)ʖ����Ք�ٴ)���wA�(KѹsU���� Jɳ-Ku�Vu���m��Ѫ��Ѫ��Ѫ��Ѫ��ժ��պ��ɺ��ɺ��ɺ��ɲ��ɲ��ٲ��ٲ��ٲ��ٶ�����BŻŻ9ʮ����݌����VŴ�ق��Rճ-Ci�Je���U��պ��ɺ��ɺ��ɺ��ɲ��ɲ��ٲ��ٲ��ٲ��ٶ��Ѷ��Ѫ��Ѫ��Ѫ��Ѫ����� Rͻ


Now I have to investigate and understand why that baud rate don't work.
regards,

Theo.

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

Re: Running demo on Arduino Mega2560

Postby tfAteba » Sun Nov 27, 2016 6:41 pm

Hi,

I made a batteries of test to understand the problem while transmitting at 115200bps.

Arduino IDE support the following baud rates for example:
300, 600 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200


So I tested those baud rates to see if they are working correctly on the ChibiOS port:

I fisrt test, with Arduino Nano board:
    The following baud rates works correctly: 300, 600, 1200, 2400, 4800 ,9600, 19200, 38400, 57600.
    The following baud rates didn't works: 115200, 230400, 250000.

The problem was the configuration of the UART and the macro used to calculate the baud rate.

To fix the problem, configurations can be made in the file os/hal/ports/AVR/hal_serial_lld.c

To set the baudrate , I used the macro UBRR2x_F instaed of UBRR:
line 84, while declaring the default_config, I changed the macro used to calculate the baud rate.

I also set the U2X0 1 to configure the UART in Asynchronous double speed mode:
line 143, in function usart0_init. UCSR0A = (1 << U2X0), to set the

I will test with others boards and give feedback then update AVR sources.

Thanks.
regards,

Theo.

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

Re: Running demo on Arduino Mega2560

Postby tfAteba » Mon Nov 28, 2016 9:22 am

Hi All,

Just a brief recap of the test of serial communication at different baud rates on others Arduino platforms that I have. So see how thing gone on.

Here is what I got while testing:
    Arduino Mega:
    ok, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400
    nok, 300, 250000

    Arduino Mega:
    ok, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400
    nok, 250000

    Arduino Mini:
    ok, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 250000
    nok, 300

As you see I tested on tree others boards and for me it seems better, we can use 115200 and even 230400bps :D. So I will commit the changes latter to have this improvement.

Thanks.
regards,

Theo.

User avatar
tfAteba
Posts: 547
Joined: Fri Oct 16, 2015 11:03 pm
Location: Strasbourg, France
Has thanked: 91 times
Been thanked: 48 times

Re: Running demo on Arduino Mega2560

Postby tfAteba » Sun Dec 04, 2016 3:16 pm

Hi all,

Changes committed to the trunk.
regards,

Theo.


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 6 guests