I have a SAM7-P256 from Olimex and followed the Jim Lynch/Eclipse tutorial and got the blinky working just fine. I’m using the Olimex ARM-USB-OCD and can step the code. BTW - thanks Jim - that was a tremendously good tutorial. In less than an hour I went from 0 to JTAG debugging.
My question relates to the USART routines offered on the Olimex site. I cloned the blinky demo so I could get the scaffolidng from blink that worked, modified the makefile, removed all the extraneous .c files, added USART code (main.c, usart.c, etc), renamed the project, gdb build target name, etc. to line it up with my usart project. I have a good build and can step into the USART code. However, when I connect my terminal software, I’m getting garbage when I let it run, but get back actual characters I type when I single step it
I checked out the USART Mode register and derived that it was setting the USART mode to normal, selected clock of MCK, 8 bits, even parity, and 2 stop bits.
u_pUSART0->US_MR = 0x08c0;
On the baud rate side, the code set it to 9600 according to the comments:
u_pUSART0->US_BRGR = 313; //((48000000)/9600x16)
So, I set my terminal software to 9600/8/E/2 and I just get garbage.
I redid the calculation for 4800 baud, rebuilt the code, reset my terminal to 4800 baud 8/E/2 and if I type an ‘f’ it echos an ‘F’ plus a ‘~}’.
I noticed that the USART demo code was always masking with an & 0x1ff any character read or written. When I changed that to 0xff and stepped the code, it would echo a lower case ‘f’ to my terminal if I typed an ‘f’. But, if I wasn’t single stepping - just let it run - then typed an ‘f’, I would get garbage back on my terminal.
Another thing I saw from single stepping was after I typed an ‘f’, got back an ‘f’ on my terminal, and kept stepping, it would go back through the read loop and read a 254 value…it was going through twice for each character I typed.
I don’t know if any SAM7-P256 user out there has successfully built and run the USART code from the Olimex web site under Eclipse/Yagarto, but if you have, I’d appreciate getting a copy of it.
Alternatively, if someone could point me to working USART code for the Olimex SAM7-P256, whether from Olimex or not, I would appreciate it.
It seems close, but yet seems very far away from working as it came from Olimex.
Thanks,
Landon