This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bad printf behavior while using interrupts

Hello,

I've been having mixed success with using the printf library function.

I'm using a cypress cy7c68013 as part of the Cypress FX2 Development Board.

I had comm port 0 working with printf statements. I had test the putchar and getchar routine I wrote by writing a simple loop that would print out the loop number and then wait for a character input.

Then I added a simple 1 second timer so that I could print out "1 second elapsed" then "2 second elapsed", etc. This is my first foray into this type of work and just wanted to cover some of the basics.

It worked in the simulation but not on the actual target ( I did not have the debugger running or anything like that). While connected to the target I would get "Q second elapsed" and then "R second elapsed".

I then futzed around with the program, testing my putchar routine and everything seemed to work correctly except for printf and trying to print an int variable.
printf( "0123456789\n" )' even worked!

The printf started to work when I added a printf statement to print out a float value.

I've come to realize that when printf does not work, the linker has it located next to the built in ISR jump.

* * * * * * * C O D E M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0007H UNIT ?C_INITSEG
000AH 0001H *** GAP ***
CODE 000BH 0003H ABSOLUTE
CODE 000EH 035CH UNIT ?PR?PRINTF?PRINTF
CODE 036AH 008EH UNIT ?C?LIB_CODE
CODE 03F8H 008CH UNIT ?C_C51STARTUP
CODE 0484H 005BH UNIT ?PR?MAIN?VMDR_CONTROLLER
CODE 04DFH 0034H UNIT ?CO?VMDR_CONTROLLER
CODE 0513H 001EH UNIT ?PR?TIMER0_ISR?VMDR_CONTROLLER
CODE 0531H 0019H UNIT ?PR?_PUTCHAR?FX2_SERIAL_IO
CODE 054AH 0017H UNIT ?PR?SETUP_IO_PORT_0?VMDR_CONTROLLER
CODE 0561H 000BH UNIT ?PR?_GETKEY?FX2_SERIAL_IO

If I relocate the printf by using: ?pr?printf?printf (0x0010) then it starts working as expected.

* * * * * * * C O D E M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0007H UNIT ?C_INITSEG
000AH 0001H *** GAP ***
CODE 000BH 0003H ABSOLUTE
000EH 0002H *** GAP ***
CODE 0010H 035CH UNIT ?PR?PRINTF?PRINTF
CODE 036CH 008EH UNIT ?C?LIB_CODE
CODE 03FAH 008CH UNIT ?C_C51STARTUP
CODE 0486H 005BH UNIT ?PR?MAIN?VMDR_CONTROLLER
CODE 04E1H 0034H UNIT ?CO?VMDR_CONTROLLER
CODE 0515H 001EH UNIT ?PR?TIMER0_ISR?VMDR_CONTROLLER
CODE 0533H 0019H UNIT ?PR?_PUTCHAR?FX2_SERIAL_IO
CODE 054CH 0017H UNIT ?PR?SETUP_IO_PORT_0?VMDR_CONTROLLER
CODE 0563H 000BH UNIT ?PR?_GETKEY?FX2_SERIAL_IO

Can anyone please explain what's going on?
I don't understand why printf would not work when located at 0x00E or 0x00F.

Thanks,
Frodak

Parents Reply Children
  • I was not trying to use printf as reentrant. When I first did the compiler squawked so I set up different flags in the ISR and had the printf elsewhere.

    I found on the Cypress site Article ID: 11915. They show to locate the program at address 0x80 and above, that would definitly be outsied the ISR jump table areas.

    Thanks everyone,
    Frodak